CoherenceTM v3.1.3
Copyright© 2000-2006 by Tangosol, Inc.

com.tangosol.net.cache
Class SerializationMap

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.AbstractKeyBasedMap
          extended by com.tangosol.util.AbstractKeySetBasedMap
              extended by com.tangosol.net.cache.SerializationMap
All Implemented Interfaces:
Map
Direct Known Subclasses:
AbstractSerializationCache

public class SerializationMap
extends AbstractKeySetBasedMap

Map implementation that stores its contents in a BinaryStore.

This implementation is mostly thread safe. To be certain, it is suggested that access to this cache is either single-threaded or gated through an object like WrapperConcurrentMap.

Since:
Coherence 2.2
Author:
cp 2003.05.26, cp 2005.11.25 updating for 3.1 using AbstractKeySetBasedMap

Nested Class Summary
 
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMap
AbstractKeySetBasedMap.EntrySet, AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry
 
Constructor Summary
SerializationMap(BinaryStore store)
          Construct a SerializationMap on top of a BinaryStore.
SerializationMap(BinaryStore store, boolean fBinaryMap)
          Construct a SerializationMap on top of a BinaryStore, optionally storing only Binary keys and values.
SerializationMap(BinaryStore store, ClassLoader loader)
          Construct a SerializationMap on top of a BinaryStore, using the passed ClassLoader for deserialization.
 
Method Summary
 void clear()
          Clear all key/value mappings.
 boolean containsValue(Object oValue)
          Returns true if this Map maps one or more keys to the specified value.
protected  void eraseStore()
          Erase all entries from the underlying store.
protected  Object fromBinary(Binary bin)
          Translate the passed Binary object into an Object object.
 Object get(Object oKey)
          Returns the value to which this map maps the specified key.
 BinaryStore getBinaryStore()
          Returns the BinaryStore that this map uses for its storage.
 CacheStatistics getCacheStatistics()
          Returns the CacheStatistics for this cache.
 ClassLoader getClassLoader()
          Returns the ClassLoader that this map uses for deserialization, if it has one.
protected  String getDescription()
          Assemble a human-readable description.
protected  Set getInternalKeySet()
          Obtain a set of keys that are represented by this Map.
protected  Map getKeyMap()
          Returns the cache of keys that are in the SerializationMap.
 boolean isBinaryMap()
          Determine if the keys and values in this map are known to be all Binary.
 Object put(Object oKey, Object oValue)
          Associates the specified value with the specified key in this map.
 void putAll(Map map)
          Copies all of the mappings from the specified map to this map.
protected  void registerKey(Object oKey)
          Register a new key for the SerializationMap.
 Object remove(Object oKey)
          Removes the mapping for this key from this map if present.
protected  boolean removeBlind(Object oKey)
          Removes the mapping for this key from this map if present.
protected  void setBinaryMap(boolean fBinary)
          Configure the Map to be aware that all the keys and values in the map are known to be Binary or not.
protected  void setBinaryStore(BinaryStore store)
          Configures the BinaryStore that this map will use for its storage.
protected  void setClassLoader(ClassLoader loader)
          Configure the ClassLoader that this map will use for deserialization.
protected  Binary toBinary(Object o)
          Translate the passed Object object into an Binary object.
 String toString()
          Returns a string representation of this Map.
protected  void unregisterKey(Object oKey)
          Unregister a key from the SerializationMap.
 
Methods inherited from class com.tangosol.util.AbstractKeySetBasedMap
containsKey, instantiateEntrySet, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, isInternalKeySetIteratorMutable, iterateKeys, size
 
Methods inherited from class com.tangosol.util.AbstractKeyBasedMap
clone, entrySet, equals, getAll, hashCode, keySet, values
 

Constructor Detail

SerializationMap

public SerializationMap(BinaryStore store)
Construct a SerializationMap on top of a BinaryStore.

Parameters:
store - the BinaryStore to use to write the serialized objects to

SerializationMap

public SerializationMap(BinaryStore store,
                        ClassLoader loader)
Construct a SerializationMap on top of a BinaryStore, using the passed ClassLoader for deserialization.

Parameters:
store - the BinaryStore to use to write the serialized objects to
loader - the ClassLoader to use for deserialization

SerializationMap

public SerializationMap(BinaryStore store,
                        boolean fBinaryMap)
Construct a SerializationMap on top of a BinaryStore, optionally storing only Binary keys and values.

Parameters:
store - the BinaryStore to use to write the serialized objects to
fBinaryMap - true indicates that this map will only manage binary keys and values
Since:
Coherence 2.4
Method Detail

clear

public void clear()
Clear all key/value mappings.

Specified by:
clear in interface Map
Overrides:
clear in class AbstractKeyBasedMap

containsValue

public boolean containsValue(Object oValue)
Returns true if this Map maps one or more keys to the specified value.

Specified by:
containsValue in interface Map
Overrides:
containsValue in class AbstractKeyBasedMap
Returns:
true if this Map maps one or more keys to the specified value, false otherwise

get

public Object get(Object oKey)
Returns the value to which this map maps the specified key.

Specified by:
get in interface Map
Specified by:
get in class AbstractKeyBasedMap
Parameters:
oKey - the key object
Returns:
the value to which this map maps the specified key, or null if the map contains no mapping for this key

put

public Object put(Object oKey,
                  Object oValue)
Associates the specified value with the specified key in this map.

Specified by:
put in interface Map
Overrides:
put in class AbstractKeyBasedMap
Parameters:
oKey - key with which the specified value is to be associated
oValue - value to be associated with the specified key
Returns:
previous value associated with specified key, or null if there was no mapping for key

putAll

public void putAll(Map map)
Copies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of calling AbstractKeyBasedMap.put(java.lang.Object, java.lang.Object) on this map once for each mapping in the passed map. The behavior of this operation is unspecified if the passed map is modified while the operation is in progress.

Specified by:
putAll in interface Map
Overrides:
putAll in class AbstractKeyBasedMap
Parameters:
map - the Map containing the key/value pairings to put into this Map

remove

public Object remove(Object oKey)
Removes the mapping for this key from this map if present. Expensive: updates both the underlying cache and the local cache.

Specified by:
remove in interface Map
Overrides:
remove in class AbstractKeyBasedMap
Parameters:
oKey - key whose mapping is to be removed from the map
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.

getInternalKeySet

protected Set getInternalKeySet()
Obtain a set of keys that are represented by this Map.

The AbstractKeySetBasedMap only utilizes the internal key set as a read-only resource.

Specified by:
getInternalKeySet in class AbstractKeySetBasedMap
Returns:
an internal Set of keys that are contained by this Map

removeBlind

protected boolean removeBlind(Object oKey)
Removes the mapping for this key from this map if present. This method exists to allow sub-classes to optmiize remove functionalitly for situations in which the original value is not required.

Overrides:
removeBlind in class AbstractKeyBasedMap
Parameters:
oKey - key whose mapping is to be removed from the map
Returns:
true iff the Map changed as the result of this operation

toString

public String toString()
Returns a string representation of this Map. The string representation consists of a list of key-value mappings in the order returned by the Map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space). Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. Keys and values are converted to strings as by String.valueOf(Object).

Overrides:
toString in class AbstractKeyBasedMap
Returns:
a String representation of this Map

getBinaryStore

public BinaryStore getBinaryStore()
Returns the BinaryStore that this map uses for its storage.

Note: This implementation assumes that the BinaryStore is only being modified by this Map instance. If you modify the BinaryStore contents, the behavior of this Map is undefined.

Returns:
the BinaryStore

setBinaryStore

protected void setBinaryStore(BinaryStore store)
Configures the BinaryStore that this map will use for its storage.

Parameters:
store - the BinaryStore to use

getClassLoader

public ClassLoader getClassLoader()
Returns the ClassLoader that this map uses for deserialization, if it has one.

Returns:
the ClassLoader that this map uses for deserialization; may be null

setClassLoader

protected void setClassLoader(ClassLoader loader)
Configure the ClassLoader that this map will use for deserialization.

Parameters:
loader - the ClassLoader that this map should use for deserialization

isBinaryMap

public boolean isBinaryMap()
Determine if the keys and values in this map are known to be all Binary.

Returns:
true if all keys and values will be Binary to start with, and thus will not require conversion
Since:
Coherence 2.4

setBinaryMap

protected void setBinaryMap(boolean fBinary)
Configure the Map to be aware that all the keys and values in the map are known to be Binary or not.

Parameters:
fBinary - pass true if all keys and values will be Binary

getKeyMap

protected Map getKeyMap()
Returns the cache of keys that are in the SerializationMap.

Returns:
the cache of keys that are in the SerializationMap

getCacheStatistics

public CacheStatistics getCacheStatistics()
Returns the CacheStatistics for this cache.

Returns:
a CacheStatistics object

getDescription

protected String getDescription()
Assemble a human-readable description.

Returns:
a description of this Map

registerKey

protected void registerKey(Object oKey)
Register a new key for the SerializationMap. This method maintains the internal key Set for the SerializationMap.

Parameters:
oKey - the key that has been added to the map

unregisterKey

protected void unregisterKey(Object oKey)
Unregister a key from the SerializationMap. This method maintains the internal key Set for the SerializationMap.

Parameters:
oKey - the key that has been removed from the map

toBinary

protected Binary toBinary(Object o)
Translate the passed Object object into an Binary object.

Parameters:
o - the Object to serialize into a Binary object
Returns:
the Binary object

fromBinary

protected Object fromBinary(Binary bin)
Translate the passed Binary object into an Object object.

Parameters:
bin - the Binary object to deserialize
Returns:
the deserialized object

eraseStore

protected void eraseStore()
Erase all entries from the underlying store.


CoherenceTM v3.1.3
Copyright© 2000-2006 by Tangosol, Inc.