Package com.google.inject.internal
Class InjectorJitBindingData
- java.lang.Object
-
- com.google.inject.internal.InjectorJitBindingData
-
final class InjectorJitBindingData extends java.lang.Object
A container for most just-in-time (JIT) binding data corresponding to an Injector. It includes @Inject constructor bindings. It does not includeMembersInjectorStore
orProvisionListenerCallbackStore
, which are still stored inInjectorImpl
.
-
-
Field Summary
Fields Modifier and Type Field Description private WeakKeySet
bannedKeys
private java.util.Set<Key<?>>
failedJitBindings
Cache of Keys that we were unable to create JIT bindings for, so we don't keep trying.private java.util.Map<Key<?>,BindingImpl<?>>
jitBindings
Just-in-time binding cache.private java.lang.Object
lock
This lock is needed for threadsafe InjectorJitBindingData accesses.private java.util.Optional<InjectorJitBindingData>
parent
-
Constructor Summary
Constructors Constructor Description InjectorJitBindingData(java.util.Optional<InjectorJitBindingData> parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addFailedJitBinding(Key<?> key)
(package private) void
banKey(Key<?> key, InjectorBindingData injectorBindingData, java.lang.Object source)
Forbids the corresponding injector and its ancestors from creating a binding tokey
.(package private) void
banKeyInParent(Key<?> key, InjectorBindingData injectorBindingData, java.lang.Object source)
Similar tobanKey(Key, InjectorBindingData, Object)
but we only begin banning the binding at the parent level.(package private) BindingImpl<?>
getJitBinding(Key<?> key)
(package private) java.util.Map<Key<?>,BindingImpl<?>>
getJitBindings()
(package private) java.util.Set<java.lang.Object>
getSourcesForBannedKey(Key<?> key)
Returns the source of a banned key.(package private) boolean
isBannedKey(Key<?> key)
Returns true ifkey
is forbidden from being bound in the injector corresponding to this data object.(package private) boolean
isFailedJitBinding(Key<?> key)
(package private) java.lang.Object
lock()
(package private) void
putJitBinding(Key<?> key, BindingImpl<?> binding)
(package private) void
removeJitBinding(Key<?> key)
-
-
-
Field Detail
-
jitBindings
private final java.util.Map<Key<?>,BindingImpl<?>> jitBindings
Just-in-time binding cache. Guarded bylock
.
-
failedJitBindings
private final java.util.Set<Key<?>> failedJitBindings
Cache of Keys that we were unable to create JIT bindings for, so we don't keep trying. Guarded bylock
.
-
bannedKeys
private final WeakKeySet bannedKeys
-
parent
private final java.util.Optional<InjectorJitBindingData> parent
-
lock
private final java.lang.Object lock
This lock is needed for threadsafe InjectorJitBindingData accesses. It corresponds to this InjectorJitBindingData's highest ancestor.
-
-
Constructor Detail
-
InjectorJitBindingData
InjectorJitBindingData(java.util.Optional<InjectorJitBindingData> parent)
-
-
Method Detail
-
getJitBindings
java.util.Map<Key<?>,BindingImpl<?>> getJitBindings()
-
getJitBinding
BindingImpl<?> getJitBinding(Key<?> key)
-
putJitBinding
void putJitBinding(Key<?> key, BindingImpl<?> binding)
-
removeJitBinding
void removeJitBinding(Key<?> key)
-
isFailedJitBinding
boolean isFailedJitBinding(Key<?> key)
-
addFailedJitBinding
void addFailedJitBinding(Key<?> key)
-
banKey
void banKey(Key<?> key, InjectorBindingData injectorBindingData, java.lang.Object source)
Forbids the corresponding injector and its ancestors from creating a binding tokey
. Child injectors ban their bound keys on their parent injectors to prevent just-in-time bindings on the parent injector that would conflict, and pass along their InjectorBindingData to control the banned key's lifetime.
-
banKeyInParent
void banKeyInParent(Key<?> key, InjectorBindingData injectorBindingData, java.lang.Object source)
Similar tobanKey(Key, InjectorBindingData, Object)
but we only begin banning the binding at the parent level. This is used to prevent JIT bindings in the parent injector from overriding explicit bindings declared in a child injector.
-
isBannedKey
boolean isBannedKey(Key<?> key)
Returns true ifkey
is forbidden from being bound in the injector corresponding to this data object. This indicates that one of the injector's children has bound the key.
-
getSourcesForBannedKey
java.util.Set<java.lang.Object> getSourcesForBannedKey(Key<?> key)
Returns the source of a banned key.
-
lock
java.lang.Object lock()
-
-