Package org.apache.axis2.jaxws.util
Class WeakKey
- java.lang.Object
-
- java.lang.ref.Reference<T>
-
- java.lang.ref.WeakReference<Object>
-
- org.apache.axis2.jaxws.util.WeakKey
-
public class WeakKey extends WeakReference<Object>
Implement a WeakReference key to be used in a collection. Being a WeakReference, it will not prevent the key from being Garbage Collected. The key can only be created with a reference queue so that users of this class provide cleanup logic which uses the items in the reference queue to cleanup entries in the collection. Note that the ReferenceQueue will contain the WeakKey instance that assocaited with the referent that was GC'd. So, the elements on the ReferenceQueue can be used to directly access and remove entries in the collection it is a key for. For example, one could do something like the following in cleanup logic: Object gcKey = null; while ((gcKey = q.poll()) != null) { WeakKey wk = (WeakKey) gcKey;removedEntry = collection.remove(wk); ... }
-
-
Constructor Summary
Constructors Constructor Description WeakKey(Object key, ReferenceQueue q)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static WeakKey
comparisonKey(Object checkKey)
Return an instance of WeakKey that can be used in comparsion operations.boolean
equals(Object o)
int
hashCode()
-
Methods inherited from class java.lang.ref.Reference
clear, clone, enqueue, get, isEnqueued, reachabilityFence
-
-
-
-
Constructor Detail
-
WeakKey
public WeakKey(Object key, ReferenceQueue q)
-
-
Method Detail
-
comparisonKey
public static WeakKey comparisonKey(Object checkKey)
Return an instance of WeakKey that can be used in comparsion operations. For example, it can be used to lookup a key in a collection that has a WeakKey as the key.- Parameters:
checkKey
- the key value- Returns:
- an instance of WeakKey for the value
-
-