org.infinispan.atomic
Class AtomicMapLookup

java.lang.Object
  extended by org.infinispan.atomic.AtomicMapLookup

public class AtomicMapLookup
extends Object

A helper that locates or safely constructs and registers atomic maps with a given cache. This should be the only way AtomicMaps are created/retrieved, to prevent concurrent creation, registration and possibly overwriting of such a map within the cache.

Since:
4.0
Author:
Manik Surtani
See Also:
AtomicMap

Constructor Summary
AtomicMapLookup()
           
 
Method Summary
static
<MK,K,V> AtomicMap<K,V>
getAtomicMap(Cache<MK,?> cache, MK key)
          Retrieves an atomic map from a given cache, stored under a given key.
static
<MK,K,V> AtomicMap<K,V>
getAtomicMap(Cache<MK,?> cache, MK key, boolean createIfAbsent)
          Retrieves an atomic map from a given cache, stored under a given key.
static
<MK,K,V> Map<K,V>
getReadOnlyAtomicMap(Cache<MK,?> cache, MK key)
          Retrieves an atomic map from a given cache, stored under a given key, for reading only.
static
<MK> void
removeAtomicMap(Cache<MK,?> cache, MK key)
          Removes the atomic map associated with the given key from the underlying cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtomicMapLookup

public AtomicMapLookup()
Method Detail

getAtomicMap

public static <MK,K,V> AtomicMap<K,V> getAtomicMap(Cache<MK,?> cache,
                                                   MK key)
Retrieves an atomic map from a given cache, stored under a given key. If an atomic map did not exist, one is created and registered in an atomic fashion.

Type Parameters:
MK - key param of the cache
K - key param of the AtomicMap
V - value param of the AtomicMap
Parameters:
cache - underlying cache
key - key under which the atomic map exists
Returns:
an AtomicMap

getAtomicMap

public static <MK,K,V> AtomicMap<K,V> getAtomicMap(Cache<MK,?> cache,
                                                   MK key,
                                                   boolean createIfAbsent)
Retrieves an atomic map from a given cache, stored under a given key.

Type Parameters:
MK - key param of the cache
K - key param of the AtomicMap
V - value param of the AtomicMap
Parameters:
cache - underlying cache
key - key under which the atomic map exists
createIfAbsent - if true, a new atomic map is created if one doesn't exist; otherwise null is returned if the map didn't exist.
Returns:
an AtomicMap, or null if one did not exist.

getReadOnlyAtomicMap

public static <MK,K,V> Map<K,V> getReadOnlyAtomicMap(Cache<MK,?> cache,
                                                     MK key)
Retrieves an atomic map from a given cache, stored under a given key, for reading only. The atomic map returned will not support updates, and if the map did not in fact exist, an empty map is returned.

Type Parameters:
MK - key param of the cache
K - key param of the AtomicMap
V - value param of the AtomicMap
Parameters:
cache - underlying cache
key - key under which the atomic map exists
Returns:
an immutable, read-only map

removeAtomicMap

public static <MK> void removeAtomicMap(Cache<MK,?> cache,
                                        MK key)
Removes the atomic map associated with the given key from the underlying cache.

Type Parameters:
MK - key param of the cache
Parameters:
cache - underlying cache
key - key under which the atomic map exists

-->

Copyright © 2011 JBoss, a division of Red Hat. All Rights Reserved.