org.objectweb.fractal.rmi.stub
Class Stub

java.lang.Object
  extended byorg.objectweb.fractal.rmi.stub.Stub
All Implemented Interfaces:
Interface, Reference

public class Stub
extends Object
implements Reference, Interface

Super class of the stub classes generated by the RmiStubFactory. A stub gives access to an interface of a Fractal component. More precisely, it gives access to the "functional" interface provided by a server interface, and also gives access to the Interface interface implemented by this server interface. The "functional" interface is implemented by a sub class of this class, while the Interface interface is implemented by this class once and for all.


Field Summary
protected  Identifier id
          The identifier of the remote object to which this stub gives access.
protected  MarshallerFactory marshallerFactory
          The marshaller factory to be used to create new invocation messages.
protected  Session_High session
          The session that gives access to the remote object.
protected  SessionIdentifier sessionId
          The identifier of the session that gives access to the remote object.
 
Constructor Summary
Stub()
          Constructs a new Stub.
 
Method Summary
 boolean equals(Object o)
          Tests if the given object is equal to this stub.
protected  void finalize()
          Finalizes this object.
 String getFcItfName()
          Returns the name of this interface inside its component.
 Component getFcItfOwner()
          Returns the component to which this interface belongs.
 Type getFcItfType()
          Returns the type of this interface.
 Identifier[] getIdentifiers()
          Returns the set of identifiers associated with this reference.
protected  Exception handleException(Exception e)
          Handles an exception that happen in this stub.
 int hashCode()
          Returns the hashcode of this stub.
protected  void invoke(Marshaller marshaller)
          Sends the marshaller with the invocation data down the protocol stack.
 boolean isFcInternalItf()
          Returns true if this interface is an internal interface.
protected  ReplyInterface prepareInvocation(Marshaller marshaller)
          Prepares the marshaller prior to marshalling invocation data.
protected  Marshaller request()
          Obtains a marshaller for marshalling invocation data.
 void setIdentifiers(Identifier[] ids)
          Sets the set of identifiers associated with this reference.
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected Identifier id
The identifier of the remote object to which this stub gives access.


marshallerFactory

protected MarshallerFactory marshallerFactory
The marshaller factory to be used to create new invocation messages.


sessionId

protected SessionIdentifier sessionId
The identifier of the session that gives access to the remote object.


session

protected Session_High session
The session that gives access to the remote object. This session is used to send the invocation messages down the protocol stack.

Constructor Detail

Stub

public Stub()
Constructs a new Stub.

Method Detail

getIdentifiers

public Identifier[] getIdentifiers()
Returns the set of identifiers associated with this reference.

Specified by:
getIdentifiers in interface Reference
Returns:
the set of identifiers associated with this reference.
See Also:
setIdentifiers(org.objectweb.jonathan.apis.binding.Identifier[])

setIdentifiers

public void setIdentifiers(Identifier[] ids)
Sets the set of identifiers associated with this reference.

Specified by:
setIdentifiers in interface Reference
Parameters:
ids - the set of identifiers to be associated with this reference.
See Also:
getIdentifiers()

getFcItfOwner

public Component getFcItfOwner()
Description copied from interface: Interface
Returns the component to which this interface belongs.

Specified by:
getFcItfOwner in interface Interface
Returns:
the Component interface of the component to which this interface belongs.

getFcItfName

public String getFcItfName()
Description copied from interface: Interface
Returns the name of this interface inside its component. This name is "unique" inside the component: more precisely, all the external interfaces of the component have distinct names, as well as all its internal interfaces. However an internal interface can have the same name as an external interface. Of course, two interfaces in two distinct components can also have the same name.

Specified by:
getFcItfName in interface Interface
Returns:
the name of this interface inside its component.

getFcItfType

public Type getFcItfType()
Description copied from interface: Interface
Returns the type of this interface. The type system is not specified here, in order to allow many type systems to be used. The basic type system specified in the org.objectweb.fractal.api.type package should be sufficient in most cases, but another one can be used if necessary.

Specified by:
getFcItfType in interface Interface
Returns:
the type of this interface.

isFcInternalItf

public boolean isFcInternalItf()
Description copied from interface: Interface
Returns true if this interface is an internal interface.

Specified by:
isFcInternalItf in interface Interface
Returns:
true if this interface is an internal interface.

request

protected Marshaller request()
                      throws MarshalException
Obtains a marshaller for marshalling invocation data.

Returns:
a marshaller for marshalling invocation data.
Throws:
MarshalException - if something goes wrong.

prepareInvocation

protected ReplyInterface prepareInvocation(Marshaller marshaller)
                                    throws MarshalException
Prepares the marshaller prior to marshalling invocation data. This preparation is protocol-specific and typically consists of adding headers to the marshaller. In line with Java method invocation semantics, a reply is expected after the remote invocation is executed; a reply interface is thus returned in order to listen for the reply.

Parameters:
marshaller - a marshaller to be used for the invocation data.
Returns:
a reply interface for listening for the reply.
Throws:
MarshalException - if something goes wrong.

invoke

protected void invoke(Marshaller marshaller)
               throws MarshalException
Sends the marshaller with the invocation data down the protocol stack.

Parameters:
marshaller - a marshaller with the invocation data.
Throws:
MarshalException - if something goes wrong.

handleException

protected Exception handleException(Exception e)
Handles an exception that happen in this stub.

Parameters:
e - an exception.
Returns:
the exception encapsulated in the given exception (if it is a ServerException, i.e., an exception that was thrown by the remote object and sent back in a reply message), or a new RemoteException encaspulating the given exception in the other cases (case of an exception that was thrown locally by the stub itself).

equals

public boolean equals(Object o)
Tests if the given object is equal to this stub.

Parameters:
o - the object to be compared to this stub.
Returns:
true if the given object is a stub whose id is equal to the id of this stub, false otherwise.

hashCode

public int hashCode()
Returns the hashcode of this stub.

Returns:
the hashcode of the id of this stub.

finalize

protected void finalize()
Finalizes this object. This method closes the session associated to this stub if it is not null.