Constructor and Description |
---|
DefaultInjector(Module... modules) |
Modifier and Type | Method and 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.
|
public DefaultInjector(Module... modules) throws DIRuntimeException
DIRuntimeException
public <T> T getInstance(Class<T> type) throws DIRuntimeException
Injector
DIRuntimeException
if the type is not bound, or an instance can not be
created.getInstance
in interface Injector
DIRuntimeException
public <T> T getInstance(Key<T> key) throws DIRuntimeException
Injector
DIRuntimeException
if the key is not bound, or an instance can
not be created.getInstance
in interface Injector
DIRuntimeException
public <T> Provider<T> getProvider(Class<T> type) throws DIRuntimeException
getProvider
in interface Injector
DIRuntimeException
public <T> Provider<T> getProvider(Key<T> key) throws DIRuntimeException
getProvider
in interface Injector
DIRuntimeException
public void injectMembers(Object object)
Injector
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.
injectMembers
in interface Injector
public void shutdown()
Injector
Copyright © 2001–2019 Apache Cayenne. All rights reserved.