org.objectweb.fractal.rmi
Class RmiBinder

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

public class RmiBinder
extends Object
implements NamingContext, BindingController

Provides a very simple binder component to create distributed bindings.

To export an object, this naming context first exports it through an object adapter, whose role is to assign an object key to this object, and to return it in an Identifier. This identifier is then encapsulated, together with a host name and a port number, in a new Identifier, which is returned to the caller.

To create a binding to an object identified by such an identifier, this naming context creates a session identifier with the host name, the port number and the object key, by using the transport and invocation protocols. A stub is then created with the session and the object identifiers, by using the stub factory. Finally this stub is returned to the caller.


Field Summary
protected  NamingContext adapter
          The object adapter used to export objects before exporting them with this naming context.
protected  ContextFactory contextFactory
          The context factory used to create hints for various methods.
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  Protocol rmi
          The invocation protocol used to send invocation messages.
protected  StubFactory stubFactory
          The factory used to create bindings to the objects identified by the names managed by this context.
protected  Protocol tcp
          The transport protocol used by the invocation protocol to send its messages.
 
Constructor Summary
RmiBinder()
          Constructs a new RmiBinder.
 
Method Summary
 void bindFc(String clientItfName, Object serverItf)
           
 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()
           
 Object lookupFc(String clientItfName)
           
 void unbindFc(String clientItfName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adapter

protected NamingContext adapter
The object adapter used to export objects before exporting them with this naming context.


stubFactory

protected StubFactory stubFactory
The factory used to create bindings to the objects identified by the names managed by this context.


contextFactory

protected ContextFactory contextFactory
The context factory used to create hints for various methods.


rmi

protected Protocol rmi
The invocation protocol used to send invocation messages.


tcp

protected Protocol tcp
The transport protocol used by the invocation protocol to send its messages.


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

RmiBinder

public RmiBinder()
Constructs a new RmiBinder.

Method Detail

listFc

public String[] listFc()
Specified by:
listFc in interface BindingController

lookupFc

public Object lookupFc(String clientItfName)
Specified by:
lookupFc in interface BindingController

bindFc

public void bindFc(String clientItfName,
                   Object serverItf)
Specified by:
bindFc in interface BindingController

unbindFc

public void unbindFc(String clientItfName)
Specified by:
unbindFc in interface BindingController

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.
See Also:
org.objectweb.jonathan.model.naming_context#export(org.objectweb.jonathan.model.name)

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.