|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.jini.collection.WeakTable
public class WeakTable
This class is designed to allow weakly held keys to weakly held
objects. For example, it can be used for smart proxy objects that
maintain equality for references to the same remote server. If a
single VM twice invokes a remote method that returns a proxy for the
same JavaSpaces(TM) server, the references returned by that method
should be the same. This allows ==
tests to work for
proxies to remote servers the same as they would for direct references
to remote servers, which also maintain this property.
Here is an example that uses this class to ensure that exactly one
copy of a java.io.Resolvable
object exists in each
VM:
private WeakTable knownProxies; public Object readResolve() { // deferred creation means this table is not allocated on the server if (knownProxies == null) knownProxies = new WeakTable(); return knownProxies.getOrAdd(remoteServer, this); }
Nested Class Summary | |
---|---|
static interface |
WeakTable.KeyGCHandler
Handler for clients that need to know when a key is removed from the table because it has been collected. |
Constructor Summary | |
---|---|
WeakTable()
Create a new WeakTable object to maintain the maps. |
|
WeakTable(WeakTable.KeyGCHandler handler)
Create a new WeakTable object to maintain the maps that calls back the designated object when keys are collected. |
Method Summary | |
---|---|
Object |
get(Object key)
Return the value associated with given key, or null
if no value can be found. |
Object |
getOrAdd(Object key,
Object proxy)
Return the object that this key maps to. |
Object |
remove(Object key)
Remove the object that the given key maps to. |
void |
removeBlanks()
Remove any blank entries from the table. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WeakTable()
public WeakTable(WeakTable.KeyGCHandler handler)
Method Detail |
---|
public Object getOrAdd(Object key, Object proxy)
public Object get(Object key)
null
if no value can be found.
public Object remove(Object key)
public void removeBlanks()
|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |