org.apache.geronimo.kernel.basic
Class BasicProxyMap

java.lang.Object
  extended by org.apache.geronimo.kernel.basic.BasicProxyMap
All Implemented Interfaces:
Map

public class BasicProxyMap
extends Object
implements Map

Streamlined version of a WeakIdentityHashMap. Provides Identity semantics with Weak References to keys. This allows proxies to be GC'ed when no longer referenced by clients. BasicProxymanager.destroyProxy() need not be invoked when a proxy is no longer needed. Note that this is not a full Map implementation. The iteration and collection capabilities of Map have been discarded to keep the implementation lightweight.

Much of this code was cribbed from the Commons Collection 3.1 implementation of ReferenceIdentityMap and AbstractReferenceMap.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
BasicProxyMap()
           
 
Method Summary
 void clear()
          Clears the map, resetting the size to zero and nullifying references to avoid garbage collection issues.
 boolean containsKey(Object key)
          Checks whether the map contains the specified key.
 boolean containsValue(Object value)
          Checks whether the map contains the specified value.
 Set entrySet()
           
 Object get(Object key)
          Gets the value mapped to the key specified.
 boolean isEmpty()
          Checks whether the map is currently empty.
 Set keySet()
           
 Object put(Object key, Object value)
          Puts a key-value entry into this map.
 void putAll(Map t)
           
 Object remove(Object key)
          Removes the specified mapping from this map.
 int size()
          Gets the size of the map.
 Collection values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

BasicProxyMap

public BasicProxyMap()
Method Detail

size

public int size()
Gets the size of the map.

Specified by:
size in interface Map
Returns:
the size

isEmpty

public boolean isEmpty()
Checks whether the map is currently empty.

Specified by:
isEmpty in interface Map
Returns:
true if the map is currently size zero

containsKey

public boolean containsKey(Object key)
Checks whether the map contains the specified key.

Specified by:
containsKey in interface Map
Parameters:
key - the key to search for
Returns:
true if the map contains the key

containsValue

public boolean containsValue(Object value)
Checks whether the map contains the specified value.

Specified by:
containsValue in interface Map
Parameters:
value - the value to search for
Returns:
true if the map contains the value

get

public Object get(Object key)
Gets the value mapped to the key specified.

Specified by:
get in interface Map
Parameters:
key - the key
Returns:
the mapped value, null if no match

put

public Object put(Object key,
                  Object value)
Puts a key-value entry into this map. Neither the key nor the value may be null.

Specified by:
put in interface Map
Parameters:
key - the key to add, must not be null
value - the value to add, must not be null
Returns:
the value previously mapped to this key, null if none

remove

public Object remove(Object key)
Removes the specified mapping from this map.

Specified by:
remove in interface Map
Parameters:
key - the mapping to remove
Returns:
the value mapped to the removed key, null if key not in map

clear

public void clear()
Clears the map, resetting the size to zero and nullifying references to avoid garbage collection issues.

Specified by:
clear in interface Map

values

public Collection values()
Specified by:
values in interface Map

putAll

public void putAll(Map t)
Specified by:
putAll in interface Map

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map

keySet

public Set keySet()
Specified by:
keySet in interface Map


Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.