Package org.apache.cayenne.di.spi
Class DefaultInjector
- java.lang.Object
-
- org.apache.cayenne.di.spi.DefaultInjector
-
-
Constructor Summary
Constructors Constructor Description DefaultInjector(Module... modules)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
getInstance(Class<T> type)
Returns a service instance bound in the container for a specific type.<T> T
getInstance(Key<T> key)
Returns a service instance bound in the container for a specific binding key.<T> Provider<T>
getProvider(Class<T> type)
<T> Provider<T>
getProvider(Key<T> key)
void
injectMembers(Object object)
Performs field injection on a given object, ignoring constructor injection.void
shutdown()
A lifecycle method that let's the injector's services to clean up their state and release resources.
-
-
-
Constructor Detail
-
DefaultInjector
public DefaultInjector(Module... modules) throws DIRuntimeException
- Throws:
DIRuntimeException
-
-
Method Detail
-
getInstance
public <T> T getInstance(Class<T> type) throws DIRuntimeException
Description copied from interface:Injector
Returns a service instance bound in the container for a specific type. ThrowsDIRuntimeException
if the type is not bound, or an instance can not be created.- Specified by:
getInstance
in interfaceInjector
- Throws:
DIRuntimeException
-
getInstance
public <T> T getInstance(Key<T> key) throws DIRuntimeException
Description copied from interface:Injector
Returns a service instance bound in the container for a specific binding key. ThrowsDIRuntimeException
if the key is not bound, or an instance can not be created.- Specified by:
getInstance
in interfaceInjector
- Throws:
DIRuntimeException
-
getProvider
public <T> Provider<T> getProvider(Class<T> type) throws DIRuntimeException
- Specified by:
getProvider
in interfaceInjector
- Throws:
DIRuntimeException
-
getProvider
public <T> Provider<T> getProvider(Key<T> key) throws DIRuntimeException
- Specified by:
getProvider
in interfaceInjector
- Throws:
DIRuntimeException
-
injectMembers
public void injectMembers(Object object)
Description copied from interface:Injector
Performs field injection on a given object, ignoring constructor injection. Since Cayenne DI injector returns fully injected objects, this method is rarely used directly.Note that using this method inside a custom DI
Provider
will most likely result in double injection, as custom provider is wrapped in a field-injecting provider by the DI container. Instead custom providers must initialize object properties manually, obtaining dependencies from Injector.- Specified by:
injectMembers
in interfaceInjector
-
shutdown
public void shutdown()
Description copied from interface:Injector
A lifecycle method that let's the injector's services to clean up their state and release resources. This method would normally generate a scope end event for the injector's one and only singleton scope.
-
-