19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.rmi.activation;
27
28 import java.lang.reflect.Constructor;
29 import java.lang.reflect.InvocationTargetException;
30 import java.rmi.MarshalledObject;
31 import java.rmi.Naming;
32 import java.rmi.Remote;
33 import java.rmi.RemoteException;
34 import java.rmi.activation.UnknownGroupException;
35 import java.rmi.activation.UnknownObjectException;
36 import java.rmi.server.RMIClassLoader;
37 import java.rmi.server.UnicastRemoteObject;
38 import java.security.AccessController;
39 import sun.security.action.GetIntegerAction;
40
41 /**
42 * An <code>ActivationGroup</code> is responsible for creating new
43 * instances of "activatable" objects in its group, informing its
44 * <code>ActivationMonitor</code> when either: its object's become
45 * active or inactive, or the group as a whole becomes inactive. <p>
46 *
47 * An <code>ActivationGroup</code> is <i>initially</i> created in one
48 * of several ways: <ul>
49 * <li>as a side-effect of creating an <code>ActivationDesc</code>
50 * without an explicit <code>ActivationGroupID</code> for the
51 * first activatable object in the group, or
52 * <li>via the <code>ActivationGroup.createGroup</code> method
53 * <li>as a side-effect of activating the first object in a group
54 * whose <code>ActivationGroupDesc</code> was only registered.</ul><p>
55 *
56 * Only the activator can <i>recreate</i> an
57 * <code>ActivationGroup</code>. The activator spawns, as needed, a
58 * separate VM (as a child process, for example) for each registered
59 * activation group and directs activation requests to the appropriate
429 * the Activator's registry. By default, the port number used to
430 * look up the activation system is defined by
431 * <code>ActivationSystem.SYSTEM_PORT</code>. This port can be
432 * overridden by setting the property
433 * <code>java.rmi.activation.port</code>.
434 *
435 * @return the activation system for the VM/group
436 * @exception ActivationException if activation system cannot be
437 * obtained or is not bound
438 * (means that it is not running)
439 * @exception UnsupportedOperationException if and only if activation is
440 * not supported by this implementation
441 * @see #setSystem
442 * @since 1.2
443 */
444 public static synchronized ActivationSystem getSystem()
445 throws ActivationException
446 {
447 if (currSystem == null) {
448 try {
449 int port = AccessController.doPrivileged(
450 new GetIntegerAction("java.rmi.activation.port",
451 ActivationSystem.SYSTEM_PORT));
452 currSystem = (ActivationSystem)
453 Naming.lookup("//:" + port +
454 "/java.rmi.activation.ActivationSystem");
455 } catch (Exception e) {
456 throw new ActivationException(
457 "unable to obtain ActivationSystem", e);
458 }
459 }
460 return currSystem;
461 }
462
463 /**
464 * This protected method is necessary for subclasses to
465 * make the <code>activeObject</code> callback to the group's
466 * monitor. The call is simply forwarded to the group's
467 * <code>ActivationMonitor</code>.
468 *
469 * @param id the object's identifier
470 * @param mobj a marshalled object containing the remote object's stub
471 * @exception UnknownObjectException if object is not registered
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.rmi.activation;
27
28 import java.lang.reflect.Constructor;
29 import java.lang.reflect.InvocationTargetException;
30 import java.rmi.MarshalledObject;
31 import java.rmi.Naming;
32 import java.rmi.Remote;
33 import java.rmi.RemoteException;
34 import java.rmi.activation.UnknownGroupException;
35 import java.rmi.activation.UnknownObjectException;
36 import java.rmi.server.RMIClassLoader;
37 import java.rmi.server.UnicastRemoteObject;
38 import java.security.AccessController;
39 import java.security.PrivilegedAction;
40
41 /**
42 * An <code>ActivationGroup</code> is responsible for creating new
43 * instances of "activatable" objects in its group, informing its
44 * <code>ActivationMonitor</code> when either: its object's become
45 * active or inactive, or the group as a whole becomes inactive. <p>
46 *
47 * An <code>ActivationGroup</code> is <i>initially</i> created in one
48 * of several ways: <ul>
49 * <li>as a side-effect of creating an <code>ActivationDesc</code>
50 * without an explicit <code>ActivationGroupID</code> for the
51 * first activatable object in the group, or
52 * <li>via the <code>ActivationGroup.createGroup</code> method
53 * <li>as a side-effect of activating the first object in a group
54 * whose <code>ActivationGroupDesc</code> was only registered.</ul><p>
55 *
56 * Only the activator can <i>recreate</i> an
57 * <code>ActivationGroup</code>. The activator spawns, as needed, a
58 * separate VM (as a child process, for example) for each registered
59 * activation group and directs activation requests to the appropriate
429 * the Activator's registry. By default, the port number used to
430 * look up the activation system is defined by
431 * <code>ActivationSystem.SYSTEM_PORT</code>. This port can be
432 * overridden by setting the property
433 * <code>java.rmi.activation.port</code>.
434 *
435 * @return the activation system for the VM/group
436 * @exception ActivationException if activation system cannot be
437 * obtained or is not bound
438 * (means that it is not running)
439 * @exception UnsupportedOperationException if and only if activation is
440 * not supported by this implementation
441 * @see #setSystem
442 * @since 1.2
443 */
444 public static synchronized ActivationSystem getSystem()
445 throws ActivationException
446 {
447 if (currSystem == null) {
448 try {
449 int port = AccessController.doPrivileged((PrivilegedAction<Integer>) () ->
450 Integer.getInteger("java.rmi.activation.port", ActivationSystem.SYSTEM_PORT));
451 currSystem = (ActivationSystem)
452 Naming.lookup("//:" + port +
453 "/java.rmi.activation.ActivationSystem");
454 } catch (Exception e) {
455 throw new ActivationException(
456 "unable to obtain ActivationSystem", e);
457 }
458 }
459 return currSystem;
460 }
461
462 /**
463 * This protected method is necessary for subclasses to
464 * make the <code>activeObject</code> callback to the group's
465 * monitor. The call is simply forwarded to the group's
466 * <code>ActivationMonitor</code>.
467 *
468 * @param id the object's identifier
469 * @param mobj a marshalled object containing the remote object's stub
470 * @exception UnknownObjectException if object is not registered
|