public class HK2InjectionManager extends Object implements org.glassfish.jersey.internal.inject.InjectionManager
InjectionManager for HK Dependency Injection Framework.| Constructor and Description |
|---|
HK2InjectionManager()
Default constructor to be able to find a
HK2InjectionManager using ServiceLoader. |
| Modifier and Type | Method and Description |
|---|---|
<U> U |
createAndInitialize(Class<U> clazz)
This method creates, injects and post-constructs an object with the given class.
|
org.glassfish.jersey.internal.inject.ForeignDescriptor |
createForeignDescriptor(org.glassfish.jersey.internal.inject.Binding binding)
Creates and registers the descriptor in the underlying DI provider and returns
ForeignDescriptor that is specific
descriptor for the underlying DI provider. |
static org.glassfish.jersey.internal.inject.InjectionManager |
createInjectionManager(org.glassfish.hk2.api.ServiceLocator locator)
Creates a new instance of
HK2InjectionManager and automatically add the provided instance of ServiceLocator
as a underlying injection manager. |
<T> List<T> |
getAllInstances(Type clazz)
Gets all services from this injection manager that implement this contract or have this implementation.
|
<T> List<org.glassfish.jersey.internal.inject.ServiceHolder<T>> |
getAllServiceHolders(Class<T> contract,
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> clazz)
Gets the best service from this injection manager that implements this contract or has this implementation.
|
<T> T |
getInstance(Class<T> clazz,
Annotation... annotations)
Gets the best service from this injection manager that implements this contract or has this implementation.
|
<T> T |
getInstance(Class<T> clazz,
String classAnalyzer)
Gets the best service from this injection manager that implements this contract or has this implementation.
|
Object |
getInstance(org.glassfish.jersey.internal.inject.ForeignDescriptor foreignDescriptor)
Gets the service instance according to
ForeignDescriptor which is specific to the underlying DI provider. |
<T> T |
getInstance(Type clazz)
Gets the best service from this injection manager that implements this contract or has this implementation.
|
org.glassfish.hk2.api.ServiceLocator |
getServiceLocator()
Returns
ServiceLocator dedicated to this instance of HK2InjectionManager. |
void |
initialize(String name,
Object parent,
org.glassfish.jersey.internal.inject.Binder... binders)
This will initialize the
InjectionManager and underlying DI provider. |
void |
inject(Object injectMe)
This will analyze 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.
|
void |
preDestroy(Object preDestroyMe)
This will analyze the given object and call the preDestroy method.
|
void |
register(org.glassfish.hk2.utilities.Binder... binder)
Register a HK2 Binder.
|
void |
register(org.glassfish.jersey.internal.inject.Binder binder)
This will register beans which are included in
Binder. |
void |
register(org.glassfish.jersey.internal.inject.Binding binding)
This will register one bean represented using fields in the provided descriptor.
|
void |
register(Iterable<org.glassfish.jersey.internal.inject.Binding> descriptors)
This will register a collection of beans represented using fields in the provided descriptors.
|
void |
shutdown()
This will shutdown the entire injection manager and underlying DI provider along with injected executors and schedulers.
|
public HK2InjectionManager()
HK2InjectionManager using ServiceLoader.public static org.glassfish.jersey.internal.inject.InjectionManager createInjectionManager(org.glassfish.hk2.api.ServiceLocator locator)
HK2InjectionManager and automatically add the provided instance of ServiceLocator
as a underlying injection manager.
Commonly used in this scenarios:
- create InjectionManager with externally provided ServiceLocator.
- create InjectionManager which is immediately put into the different InjectionManager as a parent.
locator - HK2 ServiceLocatorHK2InjectionManager with underlying ServiceLocator.public org.glassfish.hk2.api.ServiceLocator getServiceLocator()
ServiceLocator dedicated to this instance of HK2InjectionManager.ServiceLocator.public void initialize(String name, Object parent, org.glassfish.jersey.internal.inject.Binder... binders)
org.glassfish.jersey.internal.inject.InjectionManagerInjectionManager and underlying DI provider. The method may get the array of binders to
register Binding them during initialization process. name and parent are not required parameters
and can be null without the initialization exception.initialize in interface org.glassfish.jersey.internal.inject.InjectionManagername - Name of the injection manager.parent - Parent object of the underlying DI provider on which new injection manager should be dependent. A specific
DI provider checks whether the parent object is in the proper type of underlying service storage or
a proper implementation of InjectionManager.binders - Binders with descriptions to include them during initialization process.public void shutdown()
org.glassfish.jersey.internal.inject.InjectionManagershutdown in interface org.glassfish.jersey.internal.inject.InjectionManagerpublic void register(org.glassfish.jersey.internal.inject.Binding binding)
org.glassfish.jersey.internal.inject.InjectionManagerInjectionManager is able to register a bean
represented by a class or direct instance.register in interface org.glassfish.jersey.internal.inject.InjectionManagerbinding - one descriptor.ClassBinding,
InstanceBinding,
SupplierClassBinding,
SupplierInstanceBindingpublic void register(Iterable<org.glassfish.jersey.internal.inject.Binding> descriptors)
org.glassfish.jersey.internal.inject.InjectionManagerInjectionManager is able to
register a bean represented by a class or direct instance.register in interface org.glassfish.jersey.internal.inject.InjectionManagerdescriptors - collection of descriptors.ClassBinding,
InstanceBinding,
SupplierClassBinding,
SupplierInstanceBindingpublic void register(org.glassfish.jersey.internal.inject.Binder binder)
org.glassfish.jersey.internal.inject.InjectionManagerBinder. 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.register in interface org.glassfish.jersey.internal.inject.InjectionManagerbinder - collection of descriptors.ClassBinding,
InstanceBinding,
SupplierClassBinding,
SupplierInstanceBindingpublic void register(org.glassfish.hk2.utilities.Binder... binder)
org.glassfish.jersey.internal.inject.InjectionManagerregister in interface org.glassfish.jersey.internal.inject.InjectionManagerbinder - collection of descriptors.ClassBinding,
InstanceBinding,
SupplierClassBinding,
SupplierInstanceBindingpublic <U> U createAndInitialize(Class<U> clazz)
org.glassfish.jersey.internal.inject.InjectionManagercreate-class method followed by the inject-class method followed by the post-construct method.
The object created is not managed by the injection manager.
createAndInitialize in interface org.glassfish.jersey.internal.inject.InjectionManagerclazz - The non-null class to create this object from;public <T> List<org.glassfish.jersey.internal.inject.ServiceHolder<T>> getAllServiceHolders(Class<T> contract, Annotation... qualifiers)
org.glassfish.jersey.internal.inject.InjectionManagerServiceHolder.getAllServiceHolders in interface org.glassfish.jersey.internal.inject.InjectionManagerT - Instance type.contract - 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.public <T> T getInstance(Class<T> clazz, Annotation... annotations)
org.glassfish.jersey.internal.inject.InjectionManager
Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).
getInstance in interface org.glassfish.jersey.internal.inject.InjectionManagerT - Instance type.clazz - May not be null, and is the contract or concrete implementation to get the best instance of.annotations - The set of qualifiers that must match this service definition.public <T> T getInstance(Type clazz)
org.glassfish.jersey.internal.inject.InjectionManager
Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).
getInstance in interface org.glassfish.jersey.internal.inject.InjectionManagerT - Instance type.clazz - May not be null, and is the contract or concrete implementation to get the best instance of.public Object getInstance(org.glassfish.jersey.internal.inject.ForeignDescriptor foreignDescriptor)
org.glassfish.jersey.internal.inject.InjectionManagerForeignDescriptor which is specific to the underlying DI provider.getInstance in interface org.glassfish.jersey.internal.inject.InjectionManagerforeignDescriptor - DI specific descriptor.public org.glassfish.jersey.internal.inject.ForeignDescriptor createForeignDescriptor(org.glassfish.jersey.internal.inject.Binding binding)
org.glassfish.jersey.internal.inject.InjectionManagerForeignDescriptor that is specific
descriptor for the underlying DI provider.createForeignDescriptor in interface org.glassfish.jersey.internal.inject.InjectionManagerbinding - jersey descriptor.public <T> T getInstance(Class<T> clazz)
org.glassfish.jersey.internal.inject.InjectionManager
Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).
getInstance in interface org.glassfish.jersey.internal.inject.InjectionManagerT - Instance type.clazz - May not be null, and is the contract or concrete implementation to get the best instance of.public <T> T getInstance(Class<T> clazz, String classAnalyzer)
org.glassfish.jersey.internal.inject.InjectionManager
Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).
getInstance in interface org.glassfish.jersey.internal.inject.InjectionManagerT - Instance type.clazz - May not be null, and is the contract or concrete implementation to get the best instance of.classAnalyzer - -------public <T> List<T> getAllInstances(Type clazz)
org.glassfish.jersey.internal.inject.InjectionManager
Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).
getAllInstances in interface org.glassfish.jersey.internal.inject.InjectionManagerT - Instance type.clazz - May not be null, and is the contract or concrete implementation to get the best instance of.public void inject(Object injectMe)
org.glassfish.jersey.internal.inject.InjectionManagerinject in interface org.glassfish.jersey.internal.inject.InjectionManagerinjectMe - The object to be analyzed and injected intopublic void inject(Object injectMe, String classAnalyzer)
org.glassfish.jersey.internal.inject.InjectionManagerinject in interface org.glassfish.jersey.internal.inject.InjectionManagerinjectMe - The object to be analyzed and injected intopublic void preDestroy(Object preDestroyMe)
org.glassfish.jersey.internal.inject.InjectionManagerpreDestroy in interface org.glassfish.jersey.internal.inject.InjectionManagerpreDestroyMe - The object to preDestroyCopyright © 2007-2017, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.