org.apache.axis2.jaxws.util
Class WeakKey

java.lang.Object
  extended by java.lang.ref.Reference<T>
      extended by java.lang.ref.WeakReference<Object>
          extended by 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
WeakKey(Object key, ReferenceQueue q)
           
 
Method Summary
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, enqueue, get, isEnqueued
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeakKey

public WeakKey(Object key,
               ReferenceQueue q)
Method Detail

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

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


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.