setup.java

来自「书籍《JAVA面向对象程序设计》书籍的课后源代码。相信对很多人都有帮助」· Java 代码 · 共 47 行

JAVA
47
字号
///////    Setup.java    ///////
package myrmi.demo; 

import java.rmi.*;
import java.rmi.activation.*;
import java.util.Properties;


public class Setup
{
   public static void main(String args[])
                 throws Exception
   {  // Create and install a security manager 
      System.setSecurityManager(new RMISecurityManager()); 

      Properties props = new Properties(); 
      props.put("java.security.policy", path + "policy");

      ActivationGroupDesc.CommandEnvironment ace = null; 
      ActivationGroupDesc gd = new ActivationGroupDesc(props, ace);

      ActivationGroupID agi = 
         ActivationGroup.getSystem().registerGroup(gd);

      String location = "file:" + path;

      MarshalledObject data = null;
      ActivationDesc desc = new ActivationDesc 
           (agi, "myrmi.demo.FactorialImpl", 
            location, data);
      
      // Register with rmid
      //
      Factorial mri = (Factorial)Activatable.register(desc);
      System.out.println("Got the stub for the FactorialImpl");
      
      // Bind the stub to a name in the registry running on 1099
      // 
      Naming.rebind("FactorialServer", mri);
      System.out.println("Exported FactorialServer");

      System.exit(0);
   } 
   
   static String path = "/root/jvb2/source/11/ex/myrmi/demo/";
}

⌨️ 快捷键说明

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