test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -72,11 +72,11 @@
     private static Exception exception = null;
     private static String error = null;
     private static boolean done = false;
     private static ActivateMe lastResortExitObj = null;
     private static final int NUM_OBJECTS = 10;
-    private static int PORT = 2006;
+    private static int registryPort = -1;
 
     public UnregisterGroup(ActivationID id, MarshalledObject mobj)
         throws Exception
     {
         super(id, 0);

@@ -114,11 +114,11 @@
         ActivationLibrary.deactivate(this, getID());
         System.err.println("\tActivationLibrary.deactivate returned");
 
         try {
             CallbackInterface cobj =
-                (CallbackInterface)Naming.lookup("//:" + PORT + "/Callback");
+                (CallbackInterface)Naming.lookup("//:" + registryPort + "/Callback");
             cobj.inc();
         } catch (Exception e) {
             System.err.println("cobj.inc exception");
             e.printStackTrace();
         }

@@ -233,11 +233,12 @@
 
             // Wait for the object deactivation to take place first
             try {
 
                 // create reg and export callback object
-                registry = LocateRegistry.createRegistry(PORT);
+                registry = TestLibrary.createRegistryOnUnusedPort();
+                registryPort = TestLibrary.getRegistryPort(registry);
                 Callback robj = new Callback();
                 registry.bind("Callback", robj);
 
                 //get the callback object
                 int maxwait=30;