JAC project
AOPSYS
CEDRIC & LIP6 labs

org.objectweb.jac.core.dist
Class RemoteContainer

java.lang.Object
  |
  +--org.objectweb.jac.core.dist.RemoteContainer
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CORBARemoteContainer, CORBARemoteContainerStub, RMIRemoteContainerStub

public class RemoteContainer
extends Object
implements Serializable

RemoteContainer is used as a delegate by daemons (Distd) that hold remote objects.

A remote container enables JAC objects to access and manipulate objects located on other Java VMs.

Author:
Lionel Seinturier, Renaud Pawlak
See Also:
Distd, Serialized Form

Field Summary
 String name
          The name of the container.
static boolean verbose
          Verbose tells whether information message should be printed or not.
 
Constructor Summary
RemoteContainer()
          Create a new empty container.
RemoteContainer(boolean verbose)
          Create a new container.
RemoteContainer(String className, boolean verbose)
          Create a new container and instantiates an object.
 
Method Summary
static RemoteContainer bindNewContainer(String name)
          This method dynamically binds the local container to a new remote container.
 RemoteRef bindTo(String name)
          Returns a remote reference on the object corresponding to the given name.
 void copy(String name, int index, String[] fields, byte[] state, byte[] collaboration)
          Copy a state into a base object.
 boolean equals(Object container)
          Check the equality of two containers (on the name).
 byte[] getByteCodeFor(String className)
          Gets the bytecode for the given class by using the current loader.
 String getName()
          Getter method for field name.
 int instantiates(String name, String className, Object[] args, String[] fields, byte[] state, byte[] collaboration)
          This method instantiates a className object.
 byte[] invoke(int index, String methodName, byte[] args, byte[] collaboration)
          Invoke a method on a base object.
 byte[] invokeRoleMethod(int index, String methodName, byte[] args, byte[] collaboration)
           
 boolean isLocal()
          Return true if the container is local.
static boolean isLocal(String name)
          Return true if the container is local.
 void launchRemoteGUI()
          Launches a administration GUI on a remote container.
static RemoteContainer resolve(String name)
          This class method resolve a container from its name.
 void setName(String name)
          Setter method for field name.
 String toString()
          Return a textual representation of a container (its name).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

verbose

public static boolean verbose
Verbose tells whether information message should be printed or not.


name

public String name
The name of the container.

Constructor Detail

RemoteContainer

public RemoteContainer(boolean verbose)
Create a new container.

Parameters:
verbose - true if information messages are to be printed

RemoteContainer

public RemoteContainer(String className,
                       boolean verbose)
Create a new container and instantiates an object.

Parameters:
verbose - true if information messages are to be printed

RemoteContainer

public RemoteContainer()
Create a new empty container. This constructor is needed by the compiler when one tries to subclass RemoteContainer.

See Also:
RMIRemoteContainerStub
Method Detail

bindNewContainer

public static RemoteContainer bindNewContainer(String name)
This method dynamically binds the local container to a new remote container.

Parameters:
name - the remote container to bind to

getName

public String getName()
Getter method for field name.

Returns:
the container name

setName

public void setName(String name)
Setter method for field name.

Note that this method does not bind the container. It simply sets the value of field name. Use resolve(name) to bind a container to a name.

The name can be an incomplete name since it is completed by the getFullHostName method.

Parameters:
name - the name of the container
See Also:
resolve(String), Distd.getFullHostName(String)

isLocal

public static boolean isLocal(String name)
Return true if the container is local.

Parameters:
name - the container name to resolve
Returns:
true if the container is local.
See Also:
resolve(String), isLocal()

resolve

public static RemoteContainer resolve(String name)
This class method resolve a container from its name. The way the resolution is performed is protocol dependent.

Property org.objectweb.jac.dist.remoteContainerClass defines the class of the actual RemoteContainer returned (e.g. CORBARemoteContainer). If the property is not defined or if the class does not exist, RMIRemoteContainer is the default.

Returns:
the container reference

isLocal

public boolean isLocal()
Return true if the container is local.

RemoteContainer objects are always locals. RemoteContainer stubs objects (see RMIRemoteContainerStub) may not always be local.

Returns:
true if the container is local.
See Also:
Distd.containsContainer(RemoteContainer)

instantiates

public int instantiates(String name,
                        String className,
                        Object[] args,
                        String[] fields,
                        byte[] state,
                        byte[] collaboration)
This method instantiates a className object.

Clients call it to remotely instantiate an object. instantiates creates an object and returns its local JAC index.

The object's name can be null. If not, the object is registered into the local repository.

The Aspect Component Manager is upcalled to notify the system from a remote instantiation.

Parameters:
name - the name of the object
className - the class name to instantiate
args - initialization arguments for the instantiation
fields - the object fields that are part of the state
state - the state to copy
Returns:
the index of the className object
See Also:
ACManager.whenRemoteInstantiation(Wrappee,String)

copy

public void copy(String name,
                 int index,
                 String[] fields,
                 byte[] state,
                 byte[] collaboration)
Copy a state into a base object.

Parameters:
index - the base object index (see org.objectweb.jac.core.JacObject)
fields - the object fields that are part of the state
state - the state to copy

invoke

public byte[] invoke(int index,
                     String methodName,
                     byte[] args,
                     byte[] collaboration)
Invoke a method on a base object.

The base object is the remote counterpart of a local object that has been remotely instantiated by the Distd daemon.

Parameters:
index - the callee index (see org.objectweb.jac.core.JacObject)
methodName - the called method name
args - the called method arguments
collaboration - the collaboration coming from the calling host
Returns:
the result as an array of bytes (to be deserialized)

invokeRoleMethod

public byte[] invokeRoleMethod(int index,
                               String methodName,
                               byte[] args,
                               byte[] collaboration)

getByteCodeFor

public byte[] getByteCodeFor(String className)
Gets the bytecode for the given class by using the current loader.

This method is used by distributed loaders to fetch classes bytecodes from JAC remote containers that are classes repositories.

Parameters:
className - the class name
Returns:
the corresponding bytecode

bindTo

public RemoteRef bindTo(String name)
Returns a remote reference on the object corresponding to the given name.

Note: This method has been added for practical reason but introduces a implicit dependency towards the naming aspect. If the naming aspect is not woven, then this method does not mean anything and the returned remote reference is null.

Parameters:
name - the name of the object to bind to
Returns:
the corresponding remote reference

equals

public boolean equals(Object container)
Check the equality of two containers (on the name).

Overrides:
equals in class Object
Parameters:
container - the container to check
Returns:
true if the given container equals to the current container

toString

public String toString()
Return a textual representation of a container (its name).

Overrides:
toString in class Object
Returns:
a textual representation of the container

launchRemoteGUI

public void launchRemoteGUI()
Launches a administration GUI on a remote container.


Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli