FileDocCategorySizeDatePackage
PreactivateTest.javaAPI DocExample1741Wed Apr 05 11:25:42 BST 2000None

PreactivateTest.java

/*
 * This example is from the book "Java Enterprise in a Nutshell".
 * Copyright (c) 1999 by O'Reilly & Associates.  
 * You may distribute this source code for non-commercial purposes only.
 * You may study, modify, and use this example for any purpose, as long as
 * this notice is retained.  Note that this example is provided "as is",
 * WITHOUT WARRANTY of any kind either expressed or implied.
 */

import java.rmi.activation.*;
import java.rmi.registry.*;
import java.rmi.*;
import java.net.URL;
import java.net.MalformedURLException;

public class PreactivateTest {
  public static void main(String argv[]) {
    String codebaseURL = argv[0];
    String serverName = argv[1];
    try {
      MarshalledObject activationArg = new MarshalledObject(serverName);
      System.out.println("Making server...");
      ActivationGroupDesc gdesc = new ActivationGroupDesc(null, null);
      ActivationGroupID gid =
	ActivationGroup.getSystem().registerGroup(gdesc);
      ActivationGroup.createGroup(gid, gdesc, 0);
//       ThisOrThatServer serverRef =
// 	new StillActivatableServerImpl(serverName, codebaseURL, 0);
      ActivationDesc desc =
 	new ActivationDesc(gid, "jen.rmi.StillActivatableServerImpl",
			   codebaseURL, activationArg);
      System.out.println("Registering with activation server...");
      ThisOrThatServer serverRef =
 	(ThisOrThatServer)Activatable.register(desc);
      System.out.println("Registering with naming server...");
      LocateRegistry.getRegistry(1098).rebind(serverName, serverRef);
      System.out.println("Server registered with naming and activation");
    }
    catch (Exception e) {
      e.printStackTrace();
      System.out.println("Failed to register server.");
    }
    return;
  }
}