org.objectweb.jac.core.dist.rmi
Class RMIRemoteContainerStub

java.lang.Object
  |
  +--org.objectweb.jac.core.dist.RemoteContainer
        |
        +--org.objectweb.jac.core.dist.rmi.RMIRemoteContainerStub
All Implemented Interfaces:
Serializable

public class RMIRemoteContainerStub
extends RemoteContainer
implements Serializable

RMIRemoteContainerStub acts as a client stub to access a remote container. RMIRemoteContainerStub holds a RMIRemoteContainer_Stub instance. This is the client stub of the remote RMIRemoteContainer object that owns as a delegate the container that is to be accessed. Note: what we need is an instance of something that extends RemoteContainer. But we can't have an object that is both a client stub for a remote RMI object and a RemoteContainer (no multiple inheritance in Java). So we implemented this delegating scheme where:

Author:
Lionel Seinturier
See Also:
RMIRemoteContainer, Serialized Form

Field Summary
protected  RMIRemoteContainerInterf delegate
          The RMI stub where the job is to be delegated.
 
Fields inherited from class org.objectweb.jac.core.dist.RemoteContainer
name, verbose
 
Constructor Summary
RMIRemoteContainerStub(RMIRemoteContainerInterf delegate, String name)
          Create a new remote container stub.
 
Method Summary
 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.
 byte[] getByteCodeFor(String className)
          Gets the bytecode for the given class by using the current loader.
 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[] methodArgs, byte[] collaboration)
          Invoke a method on a base object.
 byte[] invokeRoleMethod(int index, String methodName, byte[] methodArgs, byte[] collaboration)
           
 
Methods inherited from class org.objectweb.jac.core.dist.RemoteContainer
bindNewContainer, equals, getName, isLocal, isLocal, launchRemoteGUI, resolve, setName, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

delegate

protected RMIRemoteContainerInterf delegate
The RMI stub where the job is to be delegated.

Constructor Detail

RMIRemoteContainerStub

public RMIRemoteContainerStub(RMIRemoteContainerInterf delegate,
                              String name)
Create a new remote container stub.

Parameters:
delegate - the stub where the job is to be delegated
name - the name of the remote container
Method Detail

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 index.

Overrides:
instantiates in class RemoteContainer
Parameters:
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
collaboration - the collaboration of the client
name - the name of the object
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.

Overrides:
copy in class RemoteContainer
Parameters:
index - the callee index (see org.objectweb.jac.core.JacObject)
fields - the object fields that are part of the state
state - the state to copy
collaboration - the collaboration of the client

invoke

public byte[] invoke(int index,
                     String methodName,
                     byte[] methodArgs,
                     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 org.objectweb.jac.dist.Distd daemon.

Overrides:
invoke in class RemoteContainer
Parameters:
index - the callee index (see org.objectweb.jac.core.JacObject)
methodName - the callee method name
methodArgs - the callee method arguments
collaboration - the collaboration coming from the calling host
Returns:
the result

invokeRoleMethod

public byte[] invokeRoleMethod(int index,
                               String methodName,
                               byte[] methodArgs,
                               byte[] collaboration)
Overrides:
invokeRoleMethod in class RemoteContainer

getByteCodeFor

public byte[] getByteCodeFor(String className)
Description copied from class: RemoteContainer
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.

Overrides:
getByteCodeFor in class RemoteContainer
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.

Overrides:
bindTo in class RemoteContainer
Parameters:
name - the name of the object to bind to
Returns:
the corresponding remote reference