📄 upperserver.java.bak
字号:
//package chapter3;
import java.io.*;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
import org.omg.CosNaming.NamingContextPackage.*;
import UpperModule.*;
public class UpperServer
{
public static void main(String[] args)
{
try
{
//初始化ORB
ORB orb=ORB.init(args,null);
//建立接口实现类UpperImpl对象,并与ORB连接。
UpperImpl upperImpl=new UpperImpl();
//取得RootPOA引用,并激活POAManager;
POA rootpoa=POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
//取得对象引用;
org.omg.CORBA.Object ref=rootpoa.servant_to_reference(upperImpl);
Upper href=UpperHelper.narrow(ref);
//取得命名上下文的根;
org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService");
//Use NamingContestExt which is part of the Interoperable
//Naming Service(INS) specification
NamingContextExt ncRef=NamingContextExtHelper.narrow(objRef);
//绑定对象引用.
String name="Upper";
NamingComponent path[]=ncRef.to_name(name);
ncRef.rebind(path,href);
System.out.println("UpperServer ready...");
//等待客户调用。
orb.run();
}
catch(Exception e)
{
System.err.println("ERROR:"+e);
e.printStackTrace(System.out);
}
System.out.println("UpperServer Exiting...");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -