⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syspropserver.java

📁 core java第二卷源代码第三章。欢迎大家下载
💻 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 + -