📄 syspropserver.java
字号:
/**
@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("corejava", "Context"),
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -