Package org.eclipse.sisu.inject
Class BeanCache<Q extends java.lang.annotation.Annotation,T>
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReference<java.lang.Object>
-
- org.eclipse.sisu.inject.BeanCache<Q,T>
-
- All Implemented Interfaces:
java.io.Serializable
final class BeanCache<Q extends java.lang.annotation.Annotation,T> extends java.util.concurrent.atomic.AtomicReference<java.lang.Object>
Atomic cache mappingBinding
s toBeanEntry
s; optimized for common case of single entries.Uses
==
instead ofequals
to compareBinding
s because we want referential equality.
-
-
Constructor Summary
Constructors Constructor Description BeanCache()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<com.google.inject.Binding<T>>
bindings()
Retrieves theBinding
references currently associated withBeanEntry
s.BeanEntry<Q,T>
create(Q qualifier, com.google.inject.Binding<T> binding, int rank)
Atomically creates a newBeanEntry
for the givenBinding
reference.private static java.util.Map
createMap(LazyBeanEntry one, LazyBeanEntry two)
java.util.Map<com.google.inject.Binding<T>,BeanEntry<Q,T>>
flush()
BeanEntry<Q,T>
remove(com.google.inject.Binding<T> binding)
Removes theBeanEntry
associated with the givenBinding
reference.-
Methods inherited from class java.util.concurrent.atomic.AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
readCache
private java.util.Map<com.google.inject.Binding<T>,BeanEntry<Q extends java.lang.annotation.Annotation,T>> readCache
-
mutated
private volatile boolean mutated
-
-
Method Detail
-
create
public BeanEntry<Q,T> create(Q qualifier, com.google.inject.Binding<T> binding, int rank)
Atomically creates a newBeanEntry
for the givenBinding
reference.- Parameters:
qualifier
- The qualifierbinding
- The bindingrank
- The assigned rank- Returns:
- Associated bean entry
-
flush
public java.util.Map<com.google.inject.Binding<T>,BeanEntry<Q,T>> flush()
- Returns:
- Read-only snapshot of the cache
-
bindings
public java.lang.Iterable<com.google.inject.Binding<T>> bindings()
Retrieves theBinding
references currently associated withBeanEntry
s.- Returns:
- Associated bindings
-
remove
public BeanEntry<Q,T> remove(com.google.inject.Binding<T> binding)
Removes theBeanEntry
associated with the givenBinding
reference.- Parameters:
binding
- The binding- Returns:
- Associated bean entry
-
createMap
private static java.util.Map createMap(LazyBeanEntry one, LazyBeanEntry two)
-
-