org.jboss.weld.util.collections
Class ConcurrentCache<K,V>

java.lang.Object
  extended by com.google.common.collect.ForwardingObject
      extended by com.google.common.collect.ForwardingMap<K,java.util.concurrent.Future<V>>
          extended by org.jboss.weld.util.collections.ConcurrentCache<K,V>
All Implemented Interfaces:
java.util.Map<K,java.util.concurrent.Future<V>>

public class ConcurrentCache<K,V>
extends com.google.common.collect.ForwardingMap<K,java.util.concurrent.Future<V>>

Represents a thread safe map

Author:
Pete Muir

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
ConcurrentCache()
          Constructor
 
Method Summary
protected  java.util.Map<K,java.util.concurrent.Future<V>> delegate()
          Gets the delegate map
<T extends V>
java.util.concurrent.Future<T>
getFuture(K key)
          Gets the Future value from the map
<T extends V>
T
getValue(K key)
          Gets a value from the map.
<E> E
putIfAbsent(K key, java.util.concurrent.Callable<E> callable)
          Adds an item to the map if it's not already there
protected  void rethrow(java.util.concurrent.ExecutionException e)
          Examines and re-throws an exception
 
Methods inherited from class com.google.common.collect.ForwardingMap
clear, containsKey, containsValue, createEntrySet, createKeySet, createValues, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class com.google.common.collect.ForwardingObject
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConcurrentCache

public ConcurrentCache()
Constructor

Method Detail

getFuture

public <T extends V> java.util.concurrent.Future<T> getFuture(K key)
Gets the Future value from the map

Parameters:
key - The key to look for
Returns:
The Future instance of the value

getValue

public <T extends V> T getValue(K key)
Gets a value from the map. Blocks until it is available

Parameters:
key - The key to look for
Returns:
The value

putIfAbsent

public <E> E putIfAbsent(K key,
                         java.util.concurrent.Callable<E> callable)
Adds an item to the map if it's not already there

Parameters:
key - The key to place the item under
callable - The item, wrapped in a Callable instance
Returns:
The item added

delegate

protected java.util.Map<K,java.util.concurrent.Future<V>> delegate()
Gets the delegate map

Overrides:
delegate in class com.google.common.collect.ForwardingMap<K,java.util.concurrent.Future<V>>
Returns:
The backing map

rethrow

protected void rethrow(java.util.concurrent.ExecutionException e)
Examines and re-throws an exception

Parameters:
e - The exception that happened during execution


Copyright © 2008-2009 Seam Framework. All Rights Reserved.