home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 9.9 KB | 254 lines |
- /*
- * @(#)ActivationDesc.java 1.11 98/03/18
- *
- * Copyright 1997, 1998 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- package java.rmi.activation;
-
- import java.lang.reflect.Method;
- import java.security.CodeSource;
- import java.rmi.MarshalledObject;
-
- /**
- * An activation descriptor contains the information necessary to
- * activate an object: <ul>
- * <li> the object's group identifier,
- * <li> the object's class name,
- * <li> the object's code source (the location of the class), and
- * <li> a "marshalled" object that can contain object specific
- * initialization data. </ul> <p>
- *
- * A descriptor registered with the activation system can be used to
- * recreate/activate the object specified by the descriptor. The
- * <code>MarshalledObject</code> in the object's descriptor is passed
- * as the second argument to the remote object's constructor for
- * object to use during reinitialization/activation.
- *
- * @author Ann Wollrath
- * @version 1.11, 03/18/98
- * @since JDK1.2
- */
- public final class ActivationDesc implements java.io.Serializable
- {
- /** the group's identifier */
- private ActivationGroupID groupID;
- /** the object's class name */
- private String className;
- /** the object's code source */
- private CodeSource source;
- /** the object's initialization data */
- private MarshalledObject data;
- /** indicates whether the object should be restarted */
- private boolean restart;
-
- /** indicate compatibility with JDK 1.2 version of class */
- private static final long serialVersionUID = 7455834104417690957L;
-
- /**
- * Constructs an object descriptor for an object whose class name
- * is <code>className</code>, that can be loaded from the
- * CodeSource, <code>source</code>, and whose initialization
- * information is <code>data</code>. If this form of the constructor
- * is used, the <code>groupID</code> defaults to the current id for
- * <code>ActivationGroup</code> for this VM. All objects with the
- * same <code>ActivationGroupID</code> are activated in the same VM.
- * Objects specified by a descriptor created by this constructor
- * will not restart automatically when the RMI activation daemon
- * starts, but will be activated on demand (via a method call to
- * the activatable object).<p>
- *
- * Note: as a side-effect of creating an <code>ActivationDesc</code>,
- * if an <code>ActivationGroup</code> for this VM is not currently
- * active, a default one is created. The default activation group
- * uses the <code>java.rmi.RMISecurityManager</code> as a security
- * manager and upon reactivation will set the properties in the
- * activated group's VM to be the current set of properties. If
- * your application needs to use a different security manager,
- * it must set the group for the VM before creating a default
- * <code>ActivationDesc</code>. See the method
- * <code>ActivationGroup.createGroup</code> for details on how
- * to create an <code>ActivationGroup</code> for the VM.
- *
- * @param className the object's fully package qualified class name
- * @param source the object's code source (from where the class is loaded)
- * @param data the object's initialization (activation) data contained
- * in marshalled form.
- * @exception ActivationException if the current group is inactive,
- * a default group could not be created, or a security manager is not
- * set.
- */
- public ActivationDesc(String className,
- CodeSource source,
- MarshalledObject data)
- throws ActivationException
- {
- this(ActivationGroup.internalCurrentGroupID(),
- className, source, data, false);
- }
-
- /**
- * Constructs an object descriptor for an object whose class name
- * is <code>className</code>, that can be loaded from the
- * CodeSource, <code>source</code>, and whose initialization
- * information is <code>data</code>. If this form of the constructor
- * is used, the <code>groupID</code> defaults to the current id for
- * <code>ActivationGroup</code> for this VM. All objects with the
- * same <code>ActivationGroupID</code> are activated in the same VM.<p>
- *
- * Note: as a side-effect of creating an <code>ActivationDesc</code>,
- * if an <code>ActivationGroup</code> for this VM is not currently
- * active, a default one is created. The default activation group
- * uses the <code>java.rmi.RMISecurityManager</code> as a security
- * manager and upon reactivation will set the properties in the
- * activated group's VM to be the current set of properties. If
- * your application needs to use a different security manager,
- * it must set the group for the VM before creating a default
- * <code>ActivationDesc</code>. See the method
- * <code>ActivationGroup.createGroup</code> for details on how
- * to create an <code>ActivationGroup</code> for the VM.
- *
- * @param className the object's fully package qualified class name
- * @param source the object's code source (from where the class is loaded)
- * @param data the object's initialization (activation) data contained
- * in marshalled form.
- * @param restart if true, the object is restarted when the activator
- * is restarted; if false, the object is activated on demand.
- * @exception ActivationException if the current group is inactive,
- * a default group could not be created, or a security manager is not
- * set.
- */
- public ActivationDesc(String className,
- CodeSource source,
- MarshalledObject data,
- boolean restart)
- throws ActivationException
- {
- this(ActivationGroup.internalCurrentGroupID(),
- className, source, data, restart);
- }
-
- /**
- * Constructs an object descriptor for an object whose class name
- * is <code>className</code> that can be loaded from the
- * CodeSource, <code>source</code>, and whose initialization
- * information is <code>data</code>. All objects with the same
- * <code>groupID</code> are activated in the same Java VM.
- *
- * @param groupID the group's identifier (obtained from registering
- * <code>ActivationSystem.registerGroup</code> method). The group
- * indicates the VM in which the object should be activated.
- * @param className the object's fully package-qualified class name
- * @param source the object's code source (from where the class is loaded)
- * @param data the object's initialization (activation) data contained
- * in marshalled form.
- * @exception IllegalArgumentException if <code>groupID</code> is null
- */
- public ActivationDesc(ActivationGroupID groupID,
- String className,
- CodeSource source,
- MarshalledObject data)
- {
- this(groupID, className, source, data, false);
- }
-
- /**
- * Constructs an object descriptor for an object whose class name
- * is <code>className</code> that can be loaded from the
- * CodeSource, <code>source</code>, and whose initialization
- * information is <code>data</code>. All objects with the same
- * <code>groupID</code> are activated in the same Java VM.
- *
- * @param groupID the group's identifier (obtained from registering
- * <code>ActivationSystem.registerGroup</code> method). The group
- * indicates the VM in which the object should be activated.
- * @param className the object's fully package-qualified class name
- * @param source the object's code source (from where the class is loaded)
- * @param data the object's initialization (activation) data contained
- * in marshalled form.
- * @param restart if true, the object is restarted when the activator
- * is restarted; if false, the object is activated on demand.
- * @exception IllegalArgumentException if <code>groupID</code> is null
- */
- public ActivationDesc(ActivationGroupID groupID,
- String className,
- CodeSource source,
- MarshalledObject data,
- boolean restart)
- {
- if (groupID == null)
- throw new IllegalArgumentException("groupID can't be null");
- this.groupID = groupID;
- this.className = className;
- this.source = source;
- this.data = data;
- this.restart = restart;
- }
-
- /**
- * Returns the group identifier for the object specified by this
- * descriptor. A group provides a way to aggregate objects into a
- * single Java virtual machine. RMI creates/activates objects with
- * the same <code>groupID</code> in the same virtual machine.
- *
- * @return the group identifier
- */
- public ActivationGroupID getGroupID()
- {
- return groupID;
- }
-
- /**
- * Returns the class name for the object specified by this
- * descriptor.
- * @return the class name
- */
- public String getClassName()
- {
- return className;
- }
-
- /**
- * Returns the code source for the object specified by
- * this descriptor.
- * @return the code source
- */
- public CodeSource getCodeSource()
- {
- return source;
- }
-
- /**
- * Returns a "marshalled object" containing intialization/activation
- * data for the object specified by this descriptor.
- * @return the object specific "initialization" data
- */
- public MarshalledObject getData()
- {
- return data;
- }
-
- /**
- * Returns the "restart" mode of the object associated with
- * this activation descriptor.
- *
- * @return true if the activatable object associated with this
- * activation descriptor should be restarted via the activation
- * daemon when the daemon comes up; otherwise it returns false
- * (meaning that the object is only activated on demand via a
- * method call).
- */
- public boolean getRestartMode()
- {
- return restart;
- }
- }
-