org.castor.cache.hashbelt.container

Class WeakReferenceContainer

Implemented Interfaces:
Container, Map

public final class WeakReferenceContainer
extends java.lang.Object
implements Container

An implementation of a container that uses weak references for storing values in the map, so that values can be removed from the map by the system when the system is under memory pressure. Keys, however, are kept strong - so contains() may well find an element, but the value may have been lost. Make sure you test for null returns from put.

Note that keys are hard references; in a situation where OutOfMemory will occur, the JVM will first wipe out all unreferenced objects whose only link is a weak reference. An out of memory will wipe all values from the maps which are currently unreferenced. The keys remain until the hashbelt containers are garbage collected, an put is called with that key or when the value should be accessed through any operation of the Container interface.

Version:
$Revision: 6907 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
Authors:
Gregory Block
Ralf Joachim
Since:
1.0

Method Summary

void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set
entrySet()
Object
get(Object key)
long
getTimestamp()
boolean
isEmpty()
Iterator
keyIterator()
Set
keySet()
Object
put(Object key, Object value)
void
putAll(Map map)
Object
remove(Object key)
int
size()
void
updateTimestamp()
Iterator
valueIterator()
Collection
values()

Method Details

clear

public void clear()
See Also:
java.util.Map.clear()

containsKey

public boolean containsKey(Object key)
See Also:
java.util.Map.containsKey(java.lang.Object)

containsValue

public boolean containsValue(Object value)
See Also:
java.util.Map.containsValue(java.lang.Object)

entrySet

public Set entrySet()
See Also:
java.util.Map.entrySet()

get

public Object get(Object key)
See Also:
java.util.Map.get(java.lang.Object)

getTimestamp

public long getTimestamp()
Specified by:
getTimestamp in interface Container

isEmpty

public boolean isEmpty()
See Also:
java.util.Map.isEmpty()

keyIterator

public Iterator keyIterator()
Specified by:
keyIterator in interface Container

keySet

public Set keySet()
See Also:
java.util.Map.keySet()

put

public Object put(Object key,
                  Object value)
See Also:
java.util.Map.put(java.lang.Object, java.lang.Object)

putAll

public void putAll(Map map)
See Also:
java.util.Map.putAll(java.util.Map)

remove

public Object remove(Object key)
See Also:
java.util.Map.remove(java.lang.Object)

size

public int size()
See Also:
java.util.Map.size()

updateTimestamp

public void updateTimestamp()
Specified by:
updateTimestamp in interface Container

valueIterator

public Iterator valueIterator()
Specified by:
valueIterator in interface Container

values

public Collection values()
See Also:
java.util.Map.values()

Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com