Question on rmid
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Srimantha_Rajapaksa
Posted On:   Friday, February 15, 2002 02:50 AM

I am using the rmid activator to activate my remote object. the activation group is created using ActivationGroup.createGroup and the ActivationDesc is created without passing the ActivationGroupID thus ensuring that the remote object is activated on the current jvm thus no JVM is spawned by the rmid.The problem is that the rmid is spawning jvms like crazy!!!!.. Below is the code sinppet for the registration of the remote object.. public static void main(String args[]) { try{ //Start the web server on port 8001 and classpath c:java ests mitests..The run method is called in the super class ClassServer itself rmisystem.setProperty("rmihome", System.getProperty("rmi.home")); new C   More>>

I am using the rmid activator to activate my remote object. the activation group is created using ActivationGroup.createGroup and the ActivationDesc is created without passing the ActivationGroupID thus ensuring that the remote object is activated on the current jvm thus no JVM is spawned by the rmid.The problem is that the rmid is spawning jvms like crazy!!!!..



Below is the code sinppet for the registration of the remote object..



			
public static void main(String args[]) {
try{
//Start the web server on port 8001 and classpath c:java ests
mitests..The run method is called in the super class ClassServer itself
rmisystem.setProperty("rmihome", System.getProperty("rmi.home"));
new ClassFileServer(8001,rmisystem.getProperty("rmihome") + "\rmiTests\classes\Serverclasses\");
System.out.println("started the webserver...");

if(System.getSecurityManager() == null){
System.setSecurityManager(new RMISecurityManager());
}

//the code below sets the environment for the rmid to either start a new JVM or use an existing JVM for the running of the remote object method
Properties props = new Properties();
props.put("java.security.policy", rmisystem.getProperty("rmihome") + File.separator + "rmitests\classes\conf\srimrmi.policy");

ActivationGroupDesc.CommandEnvironment ace = null;

ActivationGroupDesc exampleGroup = new ActivationGroupDesc(props,ace);

//Now register the ActivationGroupDesc (exampleGroup) with the activation system to obtain it's id
ActivationGroupID agi = ActivationGroup.getSystem().registerGroup(exampleGroup);
System.out.println("agi:"+ agi);
//set the ActivationGroup created to the current JVM
ActivationGroup.createGroup(agi,exampleGroup,0);
//"location" specifies the path from where the definition of the object
//requested will come from when it is requested
//this also uniquly identifies the remote object requested.


String location = "file://"+ rmisystem.getProperty("rmihome") + File.separator +"rmitests\classes\Serverclasses\";
System.out.println("location" + location );
MarshalledObject data = null;

//desc contains all the info necessary to activate the remote object.we do not specify the agi here
//so the object is activated within the same JVM
ActivationDesc desc = new ActivationDesc(ServerActivImpl.class.getName(),
location, data,true);
System.out.println("desc:"+ desc);

//Registers the remote object with the rmid so that it can be activated on demand
ServerActivInterface hai = (ServerActivInterface)Activatable.register(desc);

//bind the stub returned by the above method to hashtable like entry

Naming.rebind("//localhost:1234/ServerActivImpl", hai);
System.out.println("Bound or exported the remote object");
//System.exit(0);
}catch(Exception e){
e.printStackTrace();
}
}

}
   <<Less
About | Sitemap | Contact