info.magnolia.registry
Class RegistryMap<K,V>

java.lang.Object
  extended by info.magnolia.registry.RegistryMap<K,V>
Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values

public class RegistryMap<K,V>
extends Object

Thread safe map intended to be used for registries. Provides an atomic operation removeAndPutAll that is used to remove a set of previously added values before adding a collection of new ones. Read operations are blocked until it completes guaranteeing proper visibility.

It is common for entities in registries to also hold their identifier. The method keyFormValue can be overridden to get the identifier from the value. This removes the need to package a set of entities that should be added in a Map before calling removeAndPutAll(java.util.Collection, java.util.Map).

Version:
$Id$

Constructor Summary
RegistryMap()
           
 
Method Summary
 V get(K key)
           
 V getRequired(K key)
           
protected  K keyFromValue(V value)
           
 Collection<K> keySet()
           
 void put(K key, V value)
           
 void put(V value)
           
 void remove(K key)
           
 Set<K> removeAndPutAll(Collection<K> toRemove, Collection<V> toPut)
           
 void removeAndPutAll(Collection<K> toRemove, Map<K,V> toPut)
           
 Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistryMap

public RegistryMap()
Method Detail

get

public V get(K key)

getRequired

public V getRequired(K key)
              throws RegistrationException
Throws:
RegistrationException

put

public void put(K key,
                V value)

put

public void put(V value)

remove

public void remove(K key)

removeAndPutAll

public void removeAndPutAll(Collection<K> toRemove,
                            Map<K,V> toPut)

removeAndPutAll

public Set<K> removeAndPutAll(Collection<K> toRemove,
                              Collection<V> toPut)

keySet

public Collection<K> keySet()

values

public Collection<V> values()

keyFromValue

protected K keyFromValue(V value)


Copyright © 2003-2013 Magnolia International Ltd.. All Rights Reserved.