/** * The group's <code>inactiveObject</code> method is called * indirectly via a call to the <code>Activatable.inactive</code> * method. A remote object implementation must call * <code>Activatable</code>'s <code>inactive</code> method when * that object deactivates (the object deems that it is no longer * active). If the object does not call * <code>Activatable.inactive</code> when it deactivates, the * object will never be garbage collected since the group keeps * strong references to the objects it creates. <p> * * The group's <code>inactiveObject</code> method * unexports the remote object from the RMI runtime so that the * object can no longer receive incoming RMI calls. This call will * only succeed if the object has no pending/executing calls. If * the object does have pending/executing RMI calls, then false * will be returned. * * If the object has no pending/executing calls, the object is * removed from the RMI runtime and the group informs its * <code>ActivationMonitor</code> (via the monitor's * <code>inactiveObject</code> method) that the remote object is * not currently active so that the remote object will be * re-activated by the activator upon a subsequent activation * request. * * @param id the object's activation identifier * @returns true if the operation succeeds (the operation will * succeed if the object in currently known to be active and is * either already unexported or is currently exported and has no * pending/executing calls); false is returned if the object has * pending/executing calls in which case it cannot be deactivated * @exception UnknownObjectException if object is unknown (may already * be inactive) * @exception RemoteException if call informing monitor fails */ public boolean inactiveObject(ActivationID id) throws ActivationException, UnknownObjectException, RemoteException { try { acquireLock(id); synchronized (this) { if (groupInactive == true) throw new ActivationException("group is inactive"); } ActiveEntry entry = active.get(id); if (entry == null) { // REMIND: should this be silent? throw new UnknownObjectException("object not active"); } try { if (Activatable.unexportObject(entry.impl, false) == false) return false; } catch (NoSuchObjectException allowUnexportedObjects) { } try { super.inactiveObject(id); } catch (UnknownObjectException allowUnregisteredObjects) { } active.remove(id); } finally { releaseLock(id); checkInactiveGroup(); } return true; }
/** * The group's <code>inactiveObject</code> method is called * indirectly via a call to the <code>Activatable.inactive</code> * method. A remote object implementation must call * <code>Activatable</code>'s <code>inactive</code> method when * that object deactivates (the object deems that it is no longer * active). If the object does not call * <code>Activatable.inactive</code> when it deactivates, the * object will never be garbage collected since the group keeps * strong references to the objects it creates. <p> * * The group's <code>inactiveObject</code> method * unexports the remote object from the RMI runtime so that the * object can no longer receive incoming RMI calls. This call will * only succeed if the object has no pending/executing calls. If * the object does have pending/executing RMI calls, then false * will be returned. * * If the object has no pending/executing calls, the object is * removed from the RMI runtime and the group informs its * <code>ActivationMonitor</code> (via the monitor's * <code>inactiveObject</code> method) that the remote object is * not currently active so that the remote object will be * re-activated by the activator upon a subsequent activation * request. * * @param id the object's activation identifier * @return true if the operation succeeds (the operation will * succeed if the object in currently known to be active and is * either already unexported or is currently exported and has no * pending/executing calls); false is returned if the object has * pending/executing calls in which case it cannot be deactivated * @exception UnknownObjectException if object is unknown (may already * be inactive) * @exception RemoteException if call informing monitor fails */ public boolean inactiveObject(ActivationID id) throws ActivationException, UnknownObjectException, RemoteException { try { acquireLock(id); synchronized (this) { if (groupInactive == true) throw new ActivationException("group is inactive"); } ActiveEntry entry = active.get(id); if (entry == null) { // REMIND: should this be silent? throw new UnknownObjectException("object not active"); } try { if (Activatable.unexportObject(entry.impl, false) == false) return false; } catch (NoSuchObjectException allowUnexportedObjects) { } try { super.inactiveObject(id); } catch (UnknownObjectException allowUnregisteredObjects) { } active.remove(id); } finally { releaseLock(id); checkInactiveGroup(); } return true; }
public DownloadActivationGroup(ActivationID id, MarshalledObject mobj) throws ActivationException, RemoteException { this.id = id; Activatable.exportObject(this, id, 0); System.err.println("object activated in group"); }
public boolean inactiveObject(ActivationID id) throws ActivationException, UnknownObjectException, RemoteException { ActiveObject ao = (ActiveObject) active_objects.get(id); if (ao == null) { // rmi.93=Object was not registered or already deactivated. throw new UnknownObjectException(Messages.getString("rmi.93")); //$NON-NLS-1$ } Activatable.unexportObject(ao.getImpl(), false); super.inactiveObject(id); active_objects.remove(id); return true; }
public void testSimpleInstall() throws Exception { try { Properties props = new Properties(); ActivationGroupDesc groupDesc = new ActivationGroupDesc(props, null); System.out.println("groupDesc = " + groupDesc); System.out.flush(); ActivationSystem as = ActivationGroup.getSystem(); System.out.println("ActivationSystem = " + as); ActivationGroupID groupID = as.registerGroup(groupDesc); System.out.println("groupID = " + groupID); System.out.println("Activation group descriptor registered."); MarshalledObject data = new MarshalledObject("HelloImpl"); System.out.println("MarshalledObject data = " + data); ActivationDesc desc = new ActivationDesc(groupID, "org.apache.harmony.rmi.tests.java.rmi.activation.HelloImpl", "", null); System.out.println("Registering ActivationDesc:"); Remote stub = Activatable.register(desc); System.out.println("Activation descriptor registered: " + stub); Registry reg = LocateRegistry.getRegistry(); System.out.println("Registry = " + reg); reg.rebind("HelloImpl_Stub", stub); System.out.println("Stub bound in registry."); } catch (Throwable t) { System.out.println("Exception in HelloInstaller: " + t); t.printStackTrace(); fail("Exception in HelloInstaller: " + t); } }
public void testInactive001() { try { Activatable.inactive(null); fail(msgRaise + "ActivationException"); } catch (ActivationException ae) { } catch (Throwable e) { fail("Failed with:" + e); } }
public void testInactive002() { try { Activatable.inactive(new ActivationID(null)); fail(msgRaise + "ActivationException"); } catch (ActivationException ae) { } catch (Throwable e) { fail("Failed with:" + e); } }
public void testInactive003() { try { ActivationID aid = new ActivationID(ac); aid.activate(false); Activatable.inactive(aid); } catch (Throwable e) { fail("Failed with:" + e); } }
public static void main(String[] args) { RMID rmid = null; System.out.println("\nRegression test for bug 4510355\n"); try { TestLibrary.suggestSecurityManager("java.lang.SecurityManager"); /* * Install group class file in codebase. */ System.err.println("install class file in codebase"); URL groupURL = TestLibrary.installClassInCodebase( "MyActivationGroupImpl", "group"); System.err.println("class file installed"); /* * Start rmid. */ RMID.removeLog(); rmid = RMID.createRMIDOnEphemeralPort(); String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none"; rmid.addOptions(new String[] { execPolicyOption }); rmid.start(); /* * Create and register descriptors for custom group and an * activatable object in that group. */ System.err.println("register group"); Properties p = new Properties(); p.put("java.security.policy", TestParams.defaultGroupPolicy); CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment( null, new String[] { "--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED", "--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED", "--add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED", "--add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" }); ActivationGroupDesc groupDesc = new ActivationGroupDesc("MyActivationGroupImpl", groupURL.toExternalForm(), null, p, cmd); ActivationGroupID groupID = ActivationGroup.getSystem().registerGroup(groupDesc); System.err.println("register activatable object"); ActivationDesc desc = new ActivationDesc(groupID, "DownloadActivationGroup", null, null); Ping obj = (Ping) Activatable.register(desc); /* * Start group (by calling ping). */ System.err.println( "ping object (forces download of group's class)"); obj.ping(); System.err.println( "TEST PASSED: group's class downloaded successfully"); System.err.println("shutdown object"); obj.shutdown(); System.err.println("TEST PASSED"); } catch (Exception e) { TestLibrary.bomb(e); } finally { rmid.cleanup(); } }
public static void main(String[] args) { RMID rmid = null; System.out.println("\nRegression test for bug 4510355\n"); try { TestLibrary.suggestSecurityManager("java.lang.SecurityManager"); /* * Install group class file in codebase. */ System.err.println("install class file in codebase"); URL groupURL = TestLibrary.installClassInCodebase( "MyActivationGroupImpl", "group"); System.err.println("class file installed"); /* * Start rmid. */ RMID.removeLog(); rmid = RMID.createRMID(); String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none"; rmid.addOptions(new String[] { execPolicyOption }); rmid.start(); /* * Create and register descriptors for custom group and an * activatable object in that group. */ System.err.println("register group"); Properties p = new Properties(); p.put("java.security.policy", TestParams.defaultGroupPolicy); CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment( null, new String[] { "-XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED", "-XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED", "-XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED", "-XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" }); ActivationGroupDesc groupDesc = new ActivationGroupDesc("MyActivationGroupImpl", groupURL.toExternalForm(), null, p, cmd); ActivationGroupID groupID = ActivationGroup.getSystem().registerGroup(groupDesc); System.err.println("register activatable object"); ActivationDesc desc = new ActivationDesc(groupID, "DownloadActivationGroup", null, null); Ping obj = (Ping) Activatable.register(desc); /* * Start group (by calling ping). */ System.err.println( "ping object (forces download of group's class)"); obj.ping(); System.err.println( "TEST PASSED: group's class downloaded successfully"); System.err.println("shutdown object"); obj.shutdown(); System.err.println("TEST PASSED"); } catch (Exception e) { TestLibrary.bomb(e); } finally { rmid.cleanup(); } }