org.objectweb.carol.irmi
Class Ref

java.lang.Object
  extended by org.objectweb.carol.irmi.Ref
All Implemented Interfaces:
Externalizable, Serializable, RemoteRef, Constants

public class Ref
extends Object
implements RemoteRef, Constants

The Ref class implements the RemoteRef interface for this RMI implementation. Instances of this class are passed to a Remote object's RemoteStub implementation. These instances then get serialized and sent to the RMI client.

Author:
Rafael H. Schloming <rhs@mit.edu>
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface java.rmi.server.RemoteRef
packagePrefix, serialVersionUID
 
Fields inherited from interface org.objectweb.carol.irmi.Constants
DGC_PING, METHOD_CALL, METHOD_ERROR, METHOD_RESULT, SYSTEM_ERROR
 
Constructor Summary
Ref()
          Public noargs constructor required for serialization.
Ref(String host, int port, ObjID oid, ClientInterceptor clint)
          Constructs a Ref instance.
 
Method Summary
 void connect(Ref ref)
          Make this Ref instance identical to the given Ref.
 void done(RemoteCall call)
          Delegates to RemoteCall#done().
 void finalize()
           
 String getHost()
          Returns the remote host pointed to by this Ref.
 ObjID getOID()
          Returns the oid of this Ref.
 int getPort()
          Returns the port on the remote host pointed to by this Ref.
 String getRefClass(ObjectOutput out)
          Returns null.
 void invoke(RemoteCall call)
          Delegates to RemoteCall.executeCall().
 Object invoke(Remote rem, Method meth, Object[] args, long hash)
           
 RemoteCall newCall(RemoteObject obj, Operation[] ops, int opnum, long hash)
          Returns a new RemoteCall object.
 void readExternal(ObjectInput in)
           
 boolean remoteEquals(RemoteRef obj)
           
 int remoteHashCode()
           
 String remoteToString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ref

public Ref()
Public noargs constructor required for serialization.


Ref

public Ref(String host,
           int port,
           ObjID oid,
           ClientInterceptor clint)
Constructs a Ref instance.

Parameters:
host - the remote host
port - the port on the remote host
oid - the ObjID of the remote object
clint - a ClientInterceptor or null
Method Detail

getOID

public ObjID getOID()
Returns the oid of this Ref.

Returns:
the oid of this Ref

getHost

public String getHost()
Returns the remote host pointed to by this Ref.

Returns:
the remote host pointed to by this Ref

getPort

public int getPort()
Returns the port on the remote host pointed to by this Ref.

Returns:
the port on the remote host pointed to by this Ref

connect

public void connect(Ref ref)
Make this Ref instance identical to the given Ref.

Parameters:
ref - the ref to duplicate

invoke

public Object invoke(Remote rem,
                     Method meth,
                     Object[] args,
                     long hash)
              throws Exception
Specified by:
invoke in interface RemoteRef
Throws:
Exception

newCall

public RemoteCall newCall(RemoteObject obj,
                          Operation[] ops,
                          int opnum,
                          long hash)
Returns a new RemoteCall object. This is only used for v1.1 stubs.

Specified by:
newCall in interface RemoteRef
Parameters:
obj - the stub
ops - the operations contained by the stub
opnum - the opnum to be invoked
hash - the interface hash for this remote object
Returns:
the RemoteCall implementation for use by the v1.1. stub

invoke

public void invoke(RemoteCall call)
            throws Exception
Delegates to RemoteCall.executeCall().

Specified by:
invoke in interface RemoteRef
Parameters:
call - the RemoteCall obtained from invoking newCall(RemoteObject, Operation[], int, long)
Throws:
Exception

done

public void done(RemoteCall call)
Delegates to RemoteCall#done().

Specified by:
done in interface RemoteRef
Parameters:
call - the RemoteCall obtained from invoking newCall(RemoteObject, Operation[], int, long)

getRefClass

public String getRefClass(ObjectOutput out)
Returns null. This is important for indicating to the containg RemoteObject implementation that this Ref should be serialized and sent directly to the client rather than being replaced with a RemoteRef implementation from the client's RMI system.

Specified by:
getRefClass in interface RemoteRef
Parameters:
out - this is ignored

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

finalize

public void finalize()
Overrides:
finalize in class Object

remoteEquals

public boolean remoteEquals(RemoteRef obj)
Specified by:
remoteEquals in interface RemoteRef

remoteHashCode

public int remoteHashCode()
Specified by:
remoteHashCode in interface RemoteRef

remoteToString

public String remoteToString()
Specified by:
remoteToString in interface RemoteRef