CONTENTS | PREV | NEXT | Java Remote Method Invocation |
The activator is one of the entities that participates during the activation process. As described earlier, a faulting reference (inside a stub) calls the activator'sactivate
method to obtain a "live" reference to an activatable remote object. Upon receiving a request for activation, the activator looks up the activation descriptor for the activation identifier, id, determines the group in which the object should be activated and invokes thenewInstance
method on the activation group's instantiator (the remote interface ActivationGroup is described below). The activator initiates the execution of activation groups as necessary. For example, if an activation group for a specific group descriptor is not already executing, the activator will spawn a child VM for the activation group to establish the group in the new VM.The activator is responsible for monitoring and detecting when activation groups fail so that it can remove stale remote references from its internal tables.
package java.rmi.activation;The
public interface Activator extends java.rmi.Remote
{
java.rmi.MarshalledObject activate(ActivationID id,
boolean force)
throws UnknownObjectException, ActivationException,
java.rmi.RemoteException;
}activate
method activates the object associated with the activation identifier, id. If the activator knows the object to be active already and the force parameter is false, the stub with a "live" reference is returned immediately to the caller; otherwise, if the activator does not know that corresponding the remote object is active or the force parameter is true, the activator uses the activation descriptor information (previously registered to obtain the id) to determine the group (VM) in which the object should be activated. If a ActivationInstantiator corresponding to the object's group already exists, the activator invokes the activation instantiator'snewInstance
method passing it the id and the object's activation descriptor.If the activation instantiator/group for the object's group descriptor does not yet exist, the activator starts a new incarnation of an ActivationInstantiator executing (by spawning a child process, for example). When the activator recreates an ActivationInstantiator for a group, it must increment the group's incarnation number. Note that the incarnation number is zero-based. The activation system uses incarnation numbers to detect late
ActivationSystem.activeGroup
andActivationMonitor.inactiveGroup
calls. The activation system discards calls with an earlier incarnation number than the current number for the group.
Note - The activator must communicate both the activation group's identifier, descriptor and incarnation number when it starts up a new activation group. The activator spawns an activation group in a separate VM (as a separate or child process, for example), and therefore must pass information specifying the information necessary to create the group via theActivationGroup.createGroup
method. How the activator sends this information to the spawned process is unspecified, however, this information could be sent in the form of marshalled objects to the child process's standard input.
When the activator receives the activation group's call back (via theActivationSystem.activeGroup
method) specifying the activation group's reference and incarnation number, the activator can then invoke that activation instantiator'snewInstance
method to forward each pending activation request to the activation instantiator and return the result (a marshalled remote object reference, a stub) to each caller.Note that the activator receives a MarshalledObject instead of a Remote object so that the activator does not need to load the code for that object, or participate in distributed garbage collection for that object. If the activator kept a strong reference to the remote object, the activator would then prevent the object from being garbage collected under the normal distributed garbage collection mechanism.
The
activate
method throws ActivationException if activation fails. Activation may fail for a variety of reasons: the class could not be found, the activation group could not be contacted, etc. Theactivate
method throws UnknownObjectException if no activation descriptor for the activation identifier, id, has been previously registered with this activator. RemoteException is thrown if the remote call to the activator fails.