server.java

来自「This an example showing how idl helping 」· Java 代码 · 共 30 行

JAVA
30
字号
import org.omg.PortableServer.*;
import java.io.*;

public class Server{
	public static void main(String[] args){ 
		try{
			//Initialize the ORB
			org.omg.CORBA.ORB orb  = org.omg.CORBA.ORB.init(args, null);
			
			//Create the servant
			Data.FileServerImpl fileAccessImpl = new Data.FileServerImpl();
			
			//Initialize the root POA
			POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
			rootPOA.the_POAManager().activate();
			
			//Generate object reference
			org.omg.CORBA.Object obj = rootPOA.servant_to_reference(fileAccessImpl);
			
			//Convert the object reference to a string and display it
			//System.out.println(orb.object_to_string(obj));
			FileWriter editor = new FileWriter("ior");
			editor.write(orb.object_to_string(obj));
			editor.close();
			
			//Wait for incoming requests
			orb.run();
		} catch (Exception e) {e.printStackTrace();}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?