org.objectweb.fractal.rmi
Class RmiAdapter

java.lang.Object
  extended byorg.objectweb.fractal.rmi.RmiAdapter
All Implemented Interfaces:
BindingController, NamingContext, Runnable

public class RmiAdapter
extends Object
implements NamingContext, Runnable, BindingController

Provides a very simple object adapter component. This naming context exports an object in the following way:


Field Summary
protected  Logger logger
          The logger used to log messages.
protected  LoggerFactory loggerFactory
          The optional logger factory used to get a logger for this component.
protected  SkeletonFactory skeletonFactory
          The skeleton factory used to create skeletons for the exported objects.
 
Constructor Summary
RmiAdapter()
          Constructs a new RmiAdapter.
 
Method Summary
 void bindFc(String clientItfName, Object serverItf)
          Binds the client interface whose name is given to a server interface.
 Identifier decode(byte[] data, int offset, int length)
          Decodes an identifier from a buffer portion.
 Identifier decode(UnMarshaller u)
          Decodes an identifier from the provided unmarshaller.
 Identifier export(Object obj, Context hints)
          Creates a new identifier for the object interface designated by the obj parameter.
 String[] listFc()
          Returns the names of the client interfaces of the component to which this interface belongs.
 Object lookupFc(String clientItfName)
          Returns the interface to which the given client interface is bound.
 void run()
          Blocks the caller thread.
 void unbindFc(String clientItfName)
          Unbinds the given client interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

skeletonFactory

protected SkeletonFactory skeletonFactory
The skeleton factory used to create skeletons for the exported objects.


loggerFactory

protected LoggerFactory loggerFactory
The optional logger factory used to get a logger for this component.


logger

protected Logger logger
The logger used to log messages. May be null.

Constructor Detail

RmiAdapter

public RmiAdapter()
Constructs a new RmiAdapter.

Method Detail

listFc

public String[] listFc()
Description copied from interface: BindingController
Returns the names of the client interfaces of the component to which this interface belongs.

Specified by:
listFc in interface BindingController
Returns:
the names of the client interfaces of the component to which this interface belongs.

lookupFc

public Object lookupFc(String clientItfName)
Description copied from interface: BindingController
Returns the interface to which the given client interface is bound. More precisely, returns the server interface to which the client interface whose name is given is bound. This server interface is necessarily in the same address space as the client interface (see bindFc).

Specified by:
lookupFc in interface BindingController
Parameters:
clientItfName - the name of a client interface of the component to which this interface belongs.
Returns:
the server interface to which the given interface is bound, or null if it is not bound.

bindFc

public void bindFc(String clientItfName,
                   Object serverItf)
Description copied from interface: BindingController
Binds the client interface whose name is given to a server interface. More precisely, binds the client interface of the component to which this interface belongs, and whose name is equal to the given name, to the given server interface. The given server interface must be in the same address space as the client interface.

Specified by:
bindFc in interface BindingController
Parameters:
clientItfName - the name of a client interface of the component to which this interface belongs.
serverItf - a server interface.

unbindFc

public void unbindFc(String clientItfName)
Description copied from interface: BindingController
Unbinds the given client interface. More precisely, unbinds the client interface of the component to which this interface belongs, and whose name is equal to the given name.

Specified by:
unbindFc in interface BindingController
Parameters:
clientItfName - the name of a client interface of the component to which this interface belongs.

export

public Identifier export(Object obj,
                         Context hints)
                  throws JonathanException
Creates a new identifier for the object interface designated by the obj parameter. Note that calling the resolve method on the returned identifier should return id.

Specified by:
export in interface NamingContext
Parameters:
obj - an object.
hints - additional information.
Returns:
an identifier managed by the target naming context.
Throws:
JonathanException - if something goes wrong.

decode

public Identifier decode(byte[] data,
                         int offset,
                         int length)
                  throws JonathanException
Decodes an identifier from a buffer portion. Since identifiers are likely to be transmitted on the net, they may have to be encoded and decoded. The encoding method is borne by the Identifier interface, but the decoding methods must be borne by each naming context. This method creates an identifier (associated with the target naming context), from the length bytes of data starting at offset offset.

Specified by:
decode in interface NamingContext
Parameters:
data - the byte array to read the encoded identifier from.
offset - offset of the first byte of the encoding.
length - length of the encoding.
Returns:
a decoded identifier.
Throws:
JonathanException - if something goes wrong.

decode

public Identifier decode(UnMarshaller u)
                  throws JonathanException
Decodes an identifier from the provided unmarshaller.

Specified by:
decode in interface NamingContext
Parameters:
u - an unmarhaller;
Returns:
an identifier managed by the target naming context;
Throws:
JonathanException - if something goes wrong.

run

public void run()
Blocks the caller thread. This method is used to create a "daemon" thread when the export method is called for the time, in order to keep the JVM process alive, waiting for incoming remote method calls.

Specified by:
run in interface Runnable