uka.karmi.rmi.server
Class RemoteStub

java.lang.Object
  extended byuka.karmi.rmi.server.RemoteStub
All Implemented Interfaces:
Anonymous, Immutable, PatchableRoot, Remote, java.io.Serializable

public abstract class RemoteStub
extends java.lang.Object
implements Remote, PatchableRoot, Immutable, java.io.Serializable

Base class for remote stubs. Stub objects are remote references to server implementation objects on a remote machine. This abstract class RemoteStub is extended by concrete stub classes that are generated by the stub and skeleton generator.

A generated stub class implements a stub method for each method of a server implementation object declared in its Remote interface. This stub method is responsible for forwarding the call to the remote node by marshaling the method arguments, unmarshaling the result, and returning the result value to its calle.

A generated stub method performs the following actions:

  1. Decide whether the server implementation object is located on the local node. If that's the case, the server implementation method is invoked directly with copies of the arguments passed to the stub method.
  2. If the call is a remote one, a ClientConnection object is requested from the underlying RemoteClientRef object.
  3. ClientConnection.openSendCall() is called on the connection object for transmission of the call header.
  4. The arguments passed to the stub method are marshaled to the connection.
  5. ClientConnection.closeSendCall() is called to indicate that the call is prepared completely and can now be processed from the server machine.
  6. ClientConnection.openReceiveResult() is called. This call blocks until the result is available form the server. The result value indicated, whether the remote method completed normally, or if an exception was thrown.
  7. If the remote method completed normally, the result is unmarshaled. If an exception was thrown, the exception object is unmarshaled from the connection.
  8. ClientConnection.closeReceiveResult() is called on the connection to indicated that the remote invocation is complete and the connection can be reused for further remote calls to the same destination.
  9. The result from the remote method is returned, or the exception unmarshaled from the connection is thrown to the caller.

Stubs delegate the hashCode() and equals(Object) methods to their RemoteClientRef.

Author:
Bernhard Haumacher, Christian Nester
See Also:
RemoteClientRef.getContext(int), ClientConnection, ClientConnection.openSendCall(), ClientConnection.closeSendCall(), ClientConnection.openReceiveResult(), ClientConnection.closeReceiveResult(), Serialized Form

Field Summary
static int ID_LASTMETHOD
          There is no method defined by default that can be invoked remotely.
protected  RemoteClientRef remoteClientRef
          See BUG/0020
 
Constructor Summary
RemoteStub()
          Default contructor, transportable classes have no implicit default constructor.
 
Method Summary
protected static int _KARMI_getLastMethodID()
          Export the last method id to the super classes of this stub class to check the generation of unique method ids within a branch in the class hierarchy.
 RemoteClientRef _KARMI_getRemoteClientRef()
          See BUG/0020
 void _KARMI_setRemoteClientRef(RemoteClientRef remoteClientRef)
          See BUG/0020
protected abstract  void _KARMI_setRemoteServer(Remote server)
          Implemented in generated stub class.
 java.lang.String _KARMI_toStringMembers()
           
 boolean equals(java.lang.Object obj)
           
 java.lang.Object getOwner()
          Return the root object this object belongs to.
 int hashCode()
           
private  void readObject(java.io.ObjectInputStream s)
          Updates this stub object after unmarshaling it from an ObjectInputStream.
private  void restoreAfterUnmarshal()
          Just declare exceptions that are never thrown and forward the call to silentRestoreAfterUnmarshal().
private  void silentRestoreAfterUnmarshal()
          Updates this stub, after unmarshaling.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

remoteClientRef

protected RemoteClientRef remoteClientRef
See BUG/0020


ID_LASTMETHOD

public static final int ID_LASTMETHOD
There is no method defined by default that can be invoked remotely. Start the first method with method id zero.

See Also:
Constant Field Values
Constructor Detail

RemoteStub

public RemoteStub()
Default contructor, transportable classes have no implicit default constructor.

Method Detail

_KARMI_getRemoteClientRef

public final RemoteClientRef _KARMI_getRemoteClientRef()
See BUG/0020


_KARMI_setRemoteClientRef

public final void _KARMI_setRemoteClientRef(RemoteClientRef remoteClientRef)
See BUG/0020


_KARMI_setRemoteServer

protected abstract void _KARMI_setRemoteServer(Remote server)
Implemented in generated stub class. Stores the shortcut reference to the server object, if it is local to that stub. See BUG/0020


_KARMI_getLastMethodID

protected static int _KARMI_getLastMethodID()
Export the last method id to the super classes of this stub class to check the generation of unique method ids within a branch in the class hierarchy.


silentRestoreAfterUnmarshal

private void silentRestoreAfterUnmarshal()
Updates this stub, after unmarshaling. This method is automatically called after a stub is unmarshaled through an UnmarshalStream. It is called from readObject(java.io.ObjectInputStream), if it is unmarshaled through an ObjectInputStream.


restoreAfterUnmarshal

private void restoreAfterUnmarshal()
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
Just declare exceptions that are never thrown and forward the call to silentRestoreAfterUnmarshal(). This is because the declaration of these exceptions is required for restoreAfterUnmarshal() methods according to the uka.transport specification.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

readObject

private void readObject(java.io.ObjectInputStream s)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Updates this stub object after unmarshaling it from an ObjectInputStream.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

hashCode

public int hashCode()
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object obj)

getOwner

public final java.lang.Object getOwner()
Description copied from interface: PatchableRoot
Return the root object this object belongs to. The replicated state of a replicated object extends to all objects that are reacheable through non-transient references from the replicated root object. The traversal ends at objects implementing PatchableRoot, if the PatchableRoot.getOwner() method returns another object than the current replicated object.

Specified by:
getOwner in interface PatchableRoot
See Also:
PatchableRoot.getOwner()

_KARMI_toStringMembers

public java.lang.String _KARMI_toStringMembers()

toString

public java.lang.String toString()