| Modifier and Type | Field and Description |
|---|---|
static java.lang.Object |
ABSENT_INSTANCE |
protected java.lang.ThreadLocal<ProvisionStack> |
provisionStackThreadLocal |
| Constructor and Description |
|---|
InjectorImpl(BinderImpl binder) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
getInstance(Key<T> type,
boolean useExplicitBindings) |
<T> T |
getInstance(ProvisionStack stack,
Key<T> type,
boolean useExplicitBindings) |
<T> T |
getInstance(TypeReference<T> type)
Invokes the overloaded method
getInstance(ProvisionStack, Key, boolean)
passing an empty provision stack |
<T> Provider<? extends T> |
getProvider(TypeReference<T> key)
Returns the explicit bound provider for the specified key
|
java.lang.Object |
getValue(InjectedKey<?> key,
ProvisionStack stack) |
<T> void |
injectMembers(ProvisionStack stack,
Key<T> type,
T instance) |
<T> void |
injectMembers(TypeReference<T> type,
T instance)
Delegates the functionality to the abstract method
injectMembers(ProvisionStack, Key, Object)
passing an empty provision stack |
void |
injectStaticMembers(java.lang.Class<?> clazz)
Injects the static members of the specified class,
equivalent to execute the overloaded method
Injector.injectMembers(TypeReference, Object)
passing a null instance and the type reference
created with the provided class |
protected void |
removeStackFromThisThread()
Sets the provision stack in this thread to null,
so it should be re-started with
stackForThisThread(). |
ProvisionStack |
stackForThisThread() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, create, getInstance, getProvider, injectMemberspublic static final java.lang.Object ABSENT_INSTANCE
protected final java.lang.ThreadLocal<ProvisionStack> provisionStackThreadLocal
public InjectorImpl(BinderImpl binder)
public java.lang.Object getValue(InjectedKey<?> key, ProvisionStack stack)
public <T> T getInstance(TypeReference<T> type)
getInstance(ProvisionStack, Key, boolean)
passing an empty provision stackgetInstance in interface InjectorT - The type parametertype - The instance generic typepublic <T> void injectMembers(TypeReference<T> type, T instance)
injectMembers(ProvisionStack, Key, Object)
passing an empty provision stackinjectMembers in interface InjectorT - The type of the injected objecttype - The injected typesinstance - The object that will be injected,
if it's null, the injector handles
it like a static injectionpublic ProvisionStack stackForThisThread()
protected void removeStackFromThisThread()
stackForThisThread().
Simple explanation: There's one ProvisionStack
per thread. This is handled using a ThreadLocal
public <T> Provider<? extends T> getProvider(TypeReference<T> key)
InjectorgetProvider in interface InjectorT - The key typekey - The key type referencepublic void injectStaticMembers(java.lang.Class<?> clazz)
InjectorInjector.injectMembers(TypeReference, Object)
passing a null instance and the type reference
created with the provided classinjectStaticMembers in interface Injectorclazz - The classpublic <T> void injectMembers(ProvisionStack stack, Key<T> type, T instance)
public <T> T getInstance(Key<T> type, boolean useExplicitBindings)
public <T> T getInstance(ProvisionStack stack, Key<T> type, boolean useExplicitBindings)