Package org.eclipse.sisu.inject
Class BeanCache<Q extends java.lang.annotation.Annotation,T>
- java.lang.Object
-
- org.eclipse.sisu.inject.BeanCache<Q,T>
-
final class BeanCache<Q extends java.lang.annotation.Annotation,T> extends java.lang.ObjectAtomic cache mappingBindings toBeanEntrys; optimized for common case of single entries.Uses
==instead ofequalsto compareBindings because we want referential equality.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Objectmappingprivate static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<BeanCache,java.lang.Object>MAPPING_UPDATERprivate booleanmutatedprivate java.util.Map<com.google.inject.Binding<T>,BeanEntry<Q,T>>readCacheprivate static longserialVersionUID
-
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 theBindingreferences currently associated withBeanEntrys.BeanEntry<Q,T>create(Q qualifier, com.google.inject.Binding<T> binding, int rank)Atomically creates a newBeanEntryfor the givenBindingreference.private static java.util.MapcreateMap(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 theBeanEntryassociated with the givenBindingreference.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
MAPPING_UPDATER
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<BeanCache,java.lang.Object> MAPPING_UPDATER
-
mapping
private volatile java.lang.Object mapping
-
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 newBeanEntryfor the givenBindingreference.- 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 theBindingreferences currently associated withBeanEntrys.- Returns:
- Associated bindings
-
remove
public BeanEntry<Q,T> remove(com.google.inject.Binding<T> binding)
Removes theBeanEntryassociated with the givenBindingreference.- Parameters:
binding- The binding- Returns:
- Associated bean entry
-
createMap
private static java.util.Map createMap(LazyBeanEntry one, LazyBeanEntry two)
-
-