syspropserver.java
来自「经典教材:java核心技术卷1、卷2的所有源代码」· Java 代码 · 共 57 行
JAVA
57 行
/**
@version 1.10 2001-07-15
@author Cay Horstmann
*/
import org.omg.CosNaming.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
class SysPropImpl extends SysPropPOA
{
public String getProperty(String key)
{
return System.getProperty(key);
}
}
public class SysPropServer
{
public static void main(String args[])
{
try
{
System.out.println("Creating and initializing the ORB...");
ORB orb = ORB.init(args, null);
System.out.println("Registering server implementation with the ORB...");
POA rootpoa = (POA) orb.resolve_initial_references("RootPOA");
rootpoa.the_POAManager().activate();
SysPropImpl impl = new SysPropImpl();
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(impl);
System.out.println(orb.object_to_string(ref));
org.omg.CORBA.Object namingContextObj = orb.resolve_initial_references("NameService");
NamingContext namingContext = NamingContextHelper.narrow(namingContextObj);
NameComponent[] path =
{
new NameComponent("SysProp", "Object")
};
System.out.println("Binding server implemenation to name service...");
namingContext.rebind(path, ref);
System.out.println("Waiting for invocations from clients...");
orb.run();
}
catch (Exception e)
{
e.printStackTrace(System.out);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?