|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuka.karmi.rmi.server.RemoteServerRef
RemoteServerRef is the base class for all remote server references in KaRMI. A server reference is the transport representation for an exported server implementation object. The transport layer of KaRMI uses remote server references to address exported remote objects.
Addressing:
A remote server is addressed by two integer identifiers in the
transport layer. The first identifier objectId is
unique within the address space the server implementation
resides.
The first identifier is therefore sufficient to address a remote server in an address space. The second identifier is only used for safety reasons:
If the server implementation is deleted while there are remote references out there and a new server is exported reusing the object identifier this new server can be accessed with the old out of date reference. This leads to unpredictable behavior, because other methods than the expected are called. This situation only occurs, if the old server is forced to be unexported while there are remote references out, or the Java virtual machine that exports the server terminates and a new one is started exporting a new server with the same object identifier.
The second identifier helps to detect a situation like the one described above. In the original implementation the second identifier was a sequence number for objects in the same transport with the same objectId. But the effort of keeping track of the sequence number of all old objects can be avoided by assigning a random number as second object identifier on export. With a good random number generator it is as probable to have the situation of a new object being accessed with an old stub as with sequence numbers. The random numbers are even better than the sequence numbers if someone wants to deny access to a remote object with a faced remote reference. In this situation there are stronger requirements on the random number generation that are not fulfilled in this implementation.
There is a call counter to implement a correct unexport method. As synchronized methods are expensive it is left to the actual reference object if the call counter is used at all.
The abstract methods are normally "up calls" from the transport layer which executes the remote method invocation.
remoteEquals() must be implemented to check equality between a RemoteServerRef and a RemoteClientRef.
| Field Summary | |
int |
callCounter
if (callCounter == -1) then the RemoteServerRef is
not exported. |
ExportPoint |
ep
the export point this object is exported on |
int |
objectId
The export point's internal ids of this reference. |
int |
objectId2
|
| Constructor Summary | |
protected |
RemoteServerRef()
|
| Method Summary | |
static RemoteSkeleton |
createSkeletonFor(Remote object)
|
static RemoteStub |
createStubFor(Remote object)
|
void |
decCallCounter()
|
abstract void |
doApplicationCall(ServerConnection c)
The entry-point into the method dispatch process. |
static java.lang.String |
getClientHost()
Returns the name of the host that initiated the remote call or throws an exception if not in a remote call. |
abstract RemoteStub |
getStub()
Returns a corresponding stub object. |
void |
incCallCounter()
|
static java.lang.Object |
newInstanceRelative(java.lang.Object object,
java.lang.String className)
|
abstract boolean |
remoteEquals(RemoteStub obj)
Determines if a stub object references this server object. |
abstract void |
synchronize(RMACallback cb)
|
java.lang.String |
toString()
|
java.lang.String |
toStringMembers()
|
abstract void |
unreferenced()
Called whenever the last remote reference to this server implementation is garbage collected. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public int objectId
The first Id is the main Id to identify the object. Now consider a DGC that deletes the server side of a remote object. Later on a new remote object is build and gets the same (now free) object id. Depending on the implementation of the DGC it is more or less easy to cheat (or unexport an object with force). This results in the situation that there are invalid references that now point to a newly allocated remote object with the same identifier. If this old reference is used, a method on the wrong object is invoked. The second identifier is a sequence number for objects in the same transport with the same objectId. This second id allows the transport to detect that an out of date reference was used.
It depends on the implementation of the technology if and how this check is performed.
There is a call counter to implement a correct unexport method. As synchronized methods are expensive it is left to the actual reference object if the call counter is used at all.
public int objectId2
public ExportPoint ep
public int callCounter
(callCounter == -1) then the RemoteServerRef is
not exported.
| Constructor Detail |
protected RemoteServerRef()
| Method Detail |
public static java.lang.String getClientHost()
throws ServerNotActiveException
ServerNotActiveException - no remote call is executed
public void incCallCounter()
throws RemoteException
RemoteExceptionpublic void decCallCounter()
public abstract void doApplicationCall(ServerConnection c)
throws java.io.IOException,
java.lang.ClassNotFoundException
dispatch() method of the server
connection. The actual dispatch is done in a sub-class of
RemoteServerRef. This abstract method is
implemented for unicast servers in the
UnicastRemoteServerRef class.
c - the connection, the call came in
java.io.IOException
java.lang.ClassNotFoundExceptionServerConnection.dispatch(boolean),
UnicastRemoteServerRef.doApplicationCall(ServerConnection)public abstract void unreferenced()
Unreferencedpublic abstract RemoteStub getStub()
This stub is used during passing a remote server as argument or result in a remote method invocation.
public abstract void synchronize(RMACallback cb)
throws java.lang.Throwable
java.lang.Throwablepublic abstract boolean remoteEquals(RemoteStub obj)
public static java.lang.Object newInstanceRelative(java.lang.Object object,
java.lang.String className)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
public static RemoteStub createStubFor(Remote object)
throws RemoteException
RemoteException
public static RemoteSkeleton createSkeletonFor(Remote object)
throws RemoteException
RemoteExceptionpublic java.lang.String toStringMembers()
public java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||