【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了ConfigureServer.java提供大家参考,希望对大家有所帮助!
package server;
import java.util.*;
import java.rmi.*;
import java.rmi.activation.*;
import message.*;
public class ConfigureServer
{
public static void main(String[] args) throws Exception
{
System.setSecurityManager(new RMISecurityManager());
// Declare an instance of the interface
MessageServer srv;
String classname = "server.Server";
// the slash at the end of the URL is needed to access directory
String location = "http://brisco:8000/";
ActivationGroupDesc groupDesc = null;
MarshalledObject data = null;
ActivationGroupID id = null;
ActivationSystem system = null;
Properties props = new Properties();
props.put("java.security.policy",
"/temp/server.policy");
System.out.println("Creating Group Desc");
ActivationGroupDesc.CommandEnvironment ace = null;
groupDesc = new ActivationGroupDesc(props, ace);
System.out.println("Getting System");
system = ActivationGroup.getSystem();
System.out.println("Creating Group ID");
id = system.registerGroup(groupDesc);
// The second argument to the ActivationDesc constructor will be used
// to uniquely identify this class; it's location is relative to the
// URL-formatted String, location.
//
System.out.println("Creating Description");
ActivationDesc desc = new ActivationDesc(id,classname, location, data);
System.out.println("Registering Description");
srv = (MessageServer)Activatable.register(desc);
System.out.println("Registered and got Server_Stub");
// Bind the stub to a name in the registry running on 1099
System.out.println("Binding Server");
Naming.rebind(MessageServer.SERVER_NAME, srv);
System.out.println("Exported MessageServer");
System.exit(0);
}
}