APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.rmi.transport

public final Class ObjectTable

extends Object
Class Inheritance
Imports
java.lang.ref.ReferenceQueue, java.rmi.NoSuchObjectException, .Remote, java.rmi.dgc.VMID, java.rmi.server.ExportException, .ObjID, java.util.HashMap, .Map, sun.rmi.runtime.Log, .RuntimeUtil

Object table shared by all implementors of the Transport interface. This table maps object ids to remote object targets in this address space.
Authors
Ann Wollrath, Peter Jones

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ObjectTable.Reaper

The Reaper thread waits for notifications that weak references in the object table have been cleared.

Field Summary

Modifier and TypeField and Description
private static final long
gcInterval

maximum interval between complete garbage collections of local heap

private static GC.LatencyRequest
gcLatencyRequest

handle for GC latency request (for future cancellation)

private static final Map<WeakRef, Target>
private static int
keepAliveCount

count of non-permanent objects in table or still processing calls

private static final Object
keepAliveLock

lock guarding keepAliveCount, reaper, and gcLatencyRequest.

private static final Map<ObjectEndpoint, Target>
objTable

tables mapping to Target, keyed from ObjectEndpoint and impl object

private static Thread
reaper

thread to collect unreferenced objects from table

pack-priv static final ReferenceQueue<Object>
reapQueue

queue notified when weak refs in the table are cleared

private static final Object
tableLock

lock guarding objTable and implTable.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
decrementKeepAliveCount()

Decrements the "keep-alive count".

public static Remote

Returns:

the stub for the remote object, obj.
getStub
(Remote impl)

Returns the stub for the remote object obj passed as a parameter.

pack-priv static Target
getTarget(ObjectEndpoint oe)

Returns the target associated with the object id.

public static Target
getTarget(Remote impl)

Returns the target associated with the remote object

pack-priv static void
incrementKeepAliveCount()

Increments the "keep-alive count".

pack-priv static void
putTarget(Target target)

Add target to object table.

pack-priv static void
referenced(ObjID id, long sequenceNum, VMID vmid)

Process client VM signalling reference for given ObjID: forward to corresponding Target entry.

private static void
removeTarget(Target target)

Remove target from object table.

public static boolean

Returns:

true if operation is successful, false otherwise
unexportObject
(Remote
the remote object to be unexported
obj
,
boolean
if true, unexports the object even if there are pending or in-progress calls; if false, only unexports the object if there are no pending or in-progress calls
force
)

Remove the remote object, obj, from the RMI runtime.

pack-priv static void
unreferenced(ObjID id, long sequenceNum, VMID vmid, boolean strong)

Process client VM dropping reference for given ObjID: forward to corresponding Target entry.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

gcIntervalback to summary
private static final long gcInterval

maximum interval between complete garbage collections of local heap

gcLatencyRequestback to summary
private static GC.LatencyRequest gcLatencyRequest

handle for GC latency request (for future cancellation)

implTableback to summary
private static final Map<WeakRef, Target> implTable
keepAliveCountback to summary
private static int keepAliveCount

count of non-permanent objects in table or still processing calls

keepAliveLockback to summary
private static final Object keepAliveLock

lock guarding keepAliveCount, reaper, and gcLatencyRequest. Holders may NOT acquire a Target instance's lock or tableLock.

objTableback to summary
private static final Map<ObjectEndpoint, Target> objTable

tables mapping to Target, keyed from ObjectEndpoint and impl object

reaperback to summary
private static Thread reaper

thread to collect unreferenced objects from table

reapQueueback to summary
pack-priv static final ReferenceQueue<Object> reapQueue

queue notified when weak refs in the table are cleared

tableLockback to summary
private static final Object tableLock

lock guarding objTable and implTable. Holders MAY acquire a Target instance's lock or keepAliveLock.

Constructor Detail

ObjectTableback to summary
private ObjectTable()

Method Detail

decrementKeepAliveCountback to summary
pack-priv static void decrementKeepAliveCount()

Decrements the "keep-alive count". The "keep-alive count" is the number of non-permanent remote objects that are either in the object table or still have calls in progress. Therefore, this method should be invoked exactly once for every previously-exported non-permanent remote object that both has been removed from the object table and has no calls still in progress. If the keep-alive count is decremented to zero, then the current reaper thread is terminated to cease keeping the VM alive (and because there are no more non-permanent remote objects to reap).

getStubback to summary
public static Remote getStub(Remote impl) throws NoSuchObjectException

Returns the stub for the remote object obj passed as a parameter. This operation is only valid after the object has been exported.

Returns:Remote

the stub for the remote object, obj.

Exceptions
NoSuchObjectException:
if the stub for the remote object could not be found.
getTargetback to summary
pack-priv static Target getTarget(ObjectEndpoint oe)

Returns the target associated with the object id.

getTargetback to summary
public static Target getTarget(Remote impl)

Returns the target associated with the remote object

incrementKeepAliveCountback to summary
pack-priv static void incrementKeepAliveCount()

Increments the "keep-alive count". The "keep-alive count" is the number of non-permanent remote objects that are either in the object table or still have calls in progress. Therefore, this method should be invoked exactly once for every non-permanent remote object exported (a remote object must be exported before it can have any calls in progress). The VM is "kept alive" while the keep-alive count is greater than zero; this is accomplished by keeping a non-daemon thread running. Because non-permanent objects are those that can be garbage collected while exported, and thus those for which the "reaper" thread operates, the reaper thread also serves as the non-daemon VM keep-alive thread; a new reaper thread is created if necessary.

putTargetback to summary
pack-priv static void putTarget(Target target) throws ExportException

Add target to object table. If it is not a permanent entry, then make sure that reaper thread is running to remove collected entries and keep VM alive.

referencedback to summary
pack-priv static void referenced(ObjID id, long sequenceNum, VMID vmid)

Process client VM signalling reference for given ObjID: forward to corresponding Target entry. If ObjID is not found in table, no action is taken.

removeTargetback to summary
private static void removeTarget(Target target)

Remove target from object table.

Note

This method must only be invoked while synchronized on the "tableLock" object, because it does not do so itself.

unexportObjectback to summary
public static boolean unexportObject(Remote obj, boolean force) throws NoSuchObjectException

Remove the remote object, obj, from the RMI runtime. If successful, the object can no longer accept incoming RMI calls. If the force parameter is true, the object is forcibly unexported even if there are pending calls to the remote object or the remote object still has calls in progress. If the force parameter is false, the object is only unexported if there are no pending or in progress calls to the object.

Parameters
obj:Remote

the remote object to be unexported

force:boolean

if true, unexports the object even if there are pending or in-progress calls; if false, only unexports the object if there are no pending or in-progress calls

Returns:boolean

true if operation is successful, false otherwise

Exceptions
NoSuchObjectException:
if the remote object is not currently exported
unreferencedback to summary
pack-priv static void unreferenced(ObjID id, long sequenceNum, VMID vmid, boolean strong)

Process client VM dropping reference for given ObjID: forward to corresponding Target entry. If ObjID is not found in table, no action is taken.

sun.rmi.transport back to summary

private Class ObjectTable.Reaper

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

The Reaper thread waits for notifications that weak references in the object table have been cleared. When it receives a notification, it removes the corresponding entry from the table. Since the Reaper is created as a non-daemon thread, it also serves to keep the VM from exiting while there are objects in the table (other than permanent entries that should neither be reaped nor keep the VM alive).

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Reaperback to summary
private Reaper()

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.