public interface InjectionManager
Lifecycle methods should be called in this order:
completeRegistration()
- notifies that Jersey bootstrap has been finished and DI provider should be ready for a runtime.shutdown()
- Jersey application has been closed and DI provider should make needed cleaning steps.
All getInstance
methods can be called after completeRegistration()
method has been called because at this all
components are bound to injection manager and ready for getting.
In turn, shutdown()
method stops the possibility to use these methods and closes InjectionManager
.
Modifier and Type | Method and Description |
---|---|
void |
completeRegistration()
Completes
InjectionManager and the underlying DI provider. |
<T> T |
create(Class<T> createMe)
Creates an object with the given class.
|
<T> T |
createAndInitialize(Class<T> createMe)
Creates, injects and post-constructs an object with the given class.
|
ForeignDescriptor |
createForeignDescriptor(Binding binding)
Creates and registers the descriptor in the underlying DI provider and returns
ForeignDescriptor that is specific
descriptor for the underlying DI provider. |
<T> List<T> |
getAllInstances(Type contractOrImpl)
Gets all services from this injection manager that implement this contract or have this implementation.
|
<T> List<ServiceHolder<T>> |
getAllServiceHolders(Class<T> contractOrImpl,
Annotation... qualifiers)
Gets all services from this injection manager that implements this contract or has this implementation along with
information about the service which can be kept by
ServiceHolder . |
<T> T |
getInstance(Class<T> contractOrImpl)
Gets the best service from this injection manager that implements this contract or has this implementation.
|
<T> T |
getInstance(Class<T> contractOrImpl,
Annotation... qualifiers)
Gets the best service from this injection manager that implements this contract or has this implementation.
|
<T> T |
getInstance(Class<T> contractOrImpl,
String classAnalyzer)
Gets the best service from this injection manager that implements this contract or has this implementation.
|
Object |
getInstance(ForeignDescriptor foreignDescriptor)
Gets the service instance according to
ForeignDescriptor which is specific to the underlying DI provider. |
<T> T |
getInstance(Type contractOrImpl)
Gets the best service from this injection manager that implements this contract or has this implementation.
|
void |
inject(Object injectMe)
Analyzes the given object and inject into its fields and methods.
|
void |
inject(Object injectMe,
String classAnalyzer)
This will analyze the given object and inject into its fields and methods.
|
boolean |
isRegistrable(Class<?> clazz)
Tests whether the provided
clazz can be registered by the implementation of the InjectionManager . |
boolean |
isShutdown()
|
void |
preDestroy(Object preDestroyMe)
Analyzes the given object and call the preDestroy method.
|
void |
register(Binder binder)
Registers beans which are included in
Binder . |
void |
register(Binding binding)
Registers one bean represented using fields in the provided descriptor.
|
void |
register(Iterable<Binding> descriptors)
Registers a collection of beans represented using fields in the provided descriptors.
|
void |
register(Object provider)
Registers a provider.
|
void |
shutdown()
Shuts down the entire
InjectionManager and the underlying DI provider. |
void completeRegistration()
InjectionManager
and the underlying DI provider. All registered components are bound to injection
manager and after an invocation of this method all components are available using e.g. getInstance(Class)
.void shutdown()
InjectionManager
and the underlying DI provider.
Shutdown phase is dedicated to make some final cleaning steps regarding underlying DI provider.
boolean isShutdown()
InjectionManager
has been shutdown.void register(Binding binding)
InjectionManager
is able to register a bean
represented by a class or direct instance.binding
- one descriptor.ClassBinding
,
InstanceBinding
,
SupplierClassBinding
,
SupplierInstanceBinding
void register(Iterable<Binding> descriptors)
InjectionManager
is able to
register a bean represented by a class or direct instance.descriptors
- collection of descriptors.ClassBinding
,
InstanceBinding
,
SupplierClassBinding
,
SupplierInstanceBinding
void register(Binder binder)
Binder
. Binder
can contains all descriptors extending
Binding
or other binders which are installed together in tree-structure. This method will get all descriptors
bound in the given binder and register them in the order how the binders are installed together. In the tree structure,
the deeper on the left side will be processed first.binder
- collection of descriptors.ClassBinding
,
InstanceBinding
,
SupplierClassBinding
,
SupplierInstanceBinding
void register(Object provider) throws IllegalArgumentException
InjectionManager
should test whether the type of the object can be
registered using the method isRegistrable(Class)
. Then a caller has an certainty that the instance of the tested
class can be registered in InjectionManager
. If InjectionManager
is not able to register the provider
then IllegalArgumentException
is thrown.provider
- object that can be registered in InjectionManager
.IllegalArgumentException
- provider cannot be registered.boolean isRegistrable(Class<?> clazz)
clazz
can be registered by the implementation of the InjectionManager
.clazz
- type that is tested whether is registrable by the implementation of InjectionManager
.true
if the InjectionManager
is able to register this type.<T> T create(Class<T> createMe)
The object created is not managed by the injection manager.
createMe
- The non-null class to create this object from;<T> T createAndInitialize(Class<T> createMe)
create-class
method followed by the inject-class
method followed by the post-construct
method.
The object created is not managed by the injection manager.
createMe
- The non-null class to create this object from;<T> List<ServiceHolder<T>> getAllServiceHolders(Class<T> contractOrImpl, Annotation... qualifiers)
ServiceHolder
.T
- Instance type.contractOrImpl
- May not be null, and is the contract or concrete implementation to get the best instance of.qualifiers
- The set of qualifiers that must match this service definition.<T> T getInstance(Class<T> contractOrImpl, Annotation... qualifiers)
Use this method only if other information is not needed otherwise use, otherwise use
getAllServiceHolders(Class, Annotation...)
.
T
- Instance type.contractOrImpl
- May not be null, and is the contract or concrete implementation to get the best instance of.qualifiers
- The set of qualifiers that must match this service definition.<T> T getInstance(Class<T> contractOrImpl, String classAnalyzer)
Use this method only if other information is not needed otherwise use, otherwise use
getAllServiceHolders(Class, Annotation...)
.
T
- Instance type.contractOrImpl
- May not be null, and is the contract or concrete implementation to get the best instance of.classAnalyzer
- -------<T> T getInstance(Class<T> contractOrImpl)
Use this method only if other information is not needed otherwise use, otherwise use
getAllServiceHolders(Class, Annotation...)
.
T
- Instance type.contractOrImpl
- May not be null, and is the contract or concrete implementation to get the best instance of.<T> T getInstance(Type contractOrImpl)
Use this method only if other information is not needed otherwise use, otherwise use
getAllServiceHolders(Class, Annotation...)
.
T
- Instance type.contractOrImpl
- May not be null, and is the contract or concrete implementation to get the best instance of.Object getInstance(ForeignDescriptor foreignDescriptor)
ForeignDescriptor
which is specific to the underlying DI provider.foreignDescriptor
- DI specific descriptor.ForeignDescriptor createForeignDescriptor(Binding binding)
ForeignDescriptor
that is specific
descriptor for the underlying DI provider.binding
- jersey descriptor.<T> List<T> getAllInstances(Type contractOrImpl)
Use this method only if other information is not needed otherwise use, otherwise use
getAllServiceHolders(Class, Annotation...)
.
T
- Instance type.contractOrImpl
- May not be null, and is the contract or concrete implementation to get the best instance of.void inject(Object injectMe)
injectMe
- The object to be analyzed and injected intovoid inject(Object injectMe, String classAnalyzer)
injectMe
- The object to be analyzed and injected intovoid preDestroy(Object preDestroyMe)
preDestroyMe
- The object to preDestroyCopyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.