Class ImmediateHk2InjectionManager
- All Implemented Interfaces:
InjectionManager
InjectionManager that is able to register and inject services.- Author:
- Petr Bouda
-
Method Summary
Modifier and TypeMethodDescriptionvoidCompletesInjectionManagerand the underlying DI provider.<U> UCreates an object with the given class.<U> UcreateAndInitialize(Class<U> clazz) Creates, injects and post-constructs an object with the given class.createForeignDescriptor(Binding binding) Creates and registers the descriptor in the underlying DI provider and returnsForeignDescriptorthat is specific descriptor for the underlying DI provider.<T> List<T>getAllInstances(Type clazz) Gets all services from this injection manager that implement this contract or have this implementation.<T> List<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 byServiceHolder.<T> TgetInstance(Class<T> clazz) Gets the best service from this injection manager that implements this contract or has this implementation.<T> TgetInstance(Class<T> clazz, Annotation... annotations) Gets the best service from this injection manager that implements this contract or has this implementation.<T> TgetInstance(Class<T> clazz, String classAnalyzer) Gets the best service from this injection manager that implements this contract or has this implementation.<T> TgetInstance(Type clazz) Gets the best service from this injection manager that implements this contract or has this implementation.getInstance(ForeignDescriptor foreignDescriptor) Gets the service instance according toForeignDescriptorwhich is specific to the underlying DI provider.voidAnalyzes the given object and inject into its fields and methods.voidThis will analyze the given object and inject into its fields and methods.booleanisRegistrable(Class<?> clazz) Tests whether the providedclazzcan be registered by the implementation of theInjectionManager.booleanvoidpreDestroy(Object preDestroyMe) Analyzes the given object and call the preDestroy method.voidRegisters a collection of beans represented using fields in the provided descriptors.voidRegisters a provider.voidRegisters beans which are included inBinder.voidRegisters one bean represented using fields in the provided descriptor.voidshutdown()Shuts down the entireInjectionManagerand the underlying DI provider.
-
Method Details
-
completeRegistration
Description copied from interface:InjectionManagerCompletesInjectionManagerand 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.InjectionManager.getInstance(Class).- Throws:
IllegalStateException
-
register
Description copied from interface:InjectionManagerRegisters one bean represented using fields in the provided descriptor. The final bean can be direct bean or factory object which will create the bean at the time of injection.InjectionManageris able to register a bean represented by a class or direct instance.- Parameters:
binding- one descriptor.- See Also:
-
register
Description copied from interface:InjectionManagerRegisters a collection of beans represented using fields in the provided descriptors. The final bean can be direct bean or factory object which will create the bean at the time of injection.InjectionManageris able to register a bean represented by a class or direct instance.- Parameters:
descriptors- collection of descriptors.- See Also:
-
register
Description copied from interface:InjectionManagerRegisters beans which are included inBinder.Bindercan contains all descriptors extendingBindingor 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.- Parameters:
binder- collection of descriptors.- See Also:
-
register
Description copied from interface:InjectionManagerRegisters a provider. An implementation of theInjectionManagershould test whether the type of the object can be registered using the methodInjectionManager.isRegistrable(Class). Then a caller has an certainty that the instance of the tested class can be registered inInjectionManager. IfInjectionManageris not able to register the provider thenIllegalArgumentExceptionis thrown.- Parameters:
provider- object that can be registered inInjectionManager.
-
getServiceLocator
-
isRegistrable
Description copied from interface:InjectionManagerTests whether the providedclazzcan be registered by the implementation of theInjectionManager.- Specified by:
isRegistrablein interfaceInjectionManager- Parameters:
clazz- type that is tested whether is registrable by the implementation ofInjectionManager.- Returns:
trueif theInjectionManageris able to register this type.
-
getAllServiceHolders
Description copied from interface:InjectionManagerGets all services from this injection manager that implements this contract or has this implementation along with information about the service which can be kept byServiceHolder.- Specified by:
getAllServiceHoldersin interfaceInjectionManager- Type Parameters:
T- Instance type.- Parameters:
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.- Returns:
- An instance of the contract or impl along with other information. May return null if there is no provider that provides the given implementation or contract.
-
getInstance
Description copied from interface:InjectionManagerGets the best service from this injection manager that implements this contract or has this implementation.Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).- Specified by:
getInstancein interfaceInjectionManager- Type Parameters:
T- Instance type.- Parameters:
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.- Returns:
- An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract.
-
getInstance
Description copied from interface:InjectionManagerGets the best service from this injection manager that implements this contract or has this implementation.Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).- Specified by:
getInstancein interfaceInjectionManager- Type Parameters:
T- Instance type.- Parameters:
clazz- May not be null, and is the contract or concrete implementation to get the best instance of.- Returns:
- An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract.
-
getInstance
Description copied from interface:InjectionManagerGets the service instance according toForeignDescriptorwhich is specific to the underlying DI provider.- Specified by:
getInstancein interfaceInjectionManager- Parameters:
foreignDescriptor- DI specific descriptor.- Returns:
- service instance according to foreign descriptor.
-
getInstance
Description copied from interface:InjectionManagerGets the best service from this injection manager that implements this contract or has this implementation.Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).- Specified by:
getInstancein interfaceInjectionManager- Type Parameters:
T- Instance type.- Parameters:
clazz- May not be null, and is the contract or concrete implementation to get the best instance of.- Returns:
- An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract.
-
getInstance
Description copied from interface:InjectionManagerGets the best service from this injection manager that implements this contract or has this implementation.Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).- Specified by:
getInstancein interfaceInjectionManager- Type Parameters:
T- Instance type.- Parameters:
clazz- May not be null, and is the contract or concrete implementation to get the best instance of.classAnalyzer- -------- Returns:
- An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract.
-
getAllInstances
Description copied from interface:InjectionManagerGets all services from this injection manager that implement this contract or have this implementation.Use this method only if other information is not needed otherwise use, otherwise use
InjectionManager.getAllServiceHolders(Class, Annotation...).- Specified by:
getAllInstancesin interfaceInjectionManager- Type Parameters:
T- Instance type.- Parameters:
clazz- May not be null, and is the contract or concrete implementation to get the best instance of.- Returns:
- A list of services implementing this contract or concrete implementation. May not return null, but may return an empty list
-
preDestroy
Description copied from interface:InjectionManagerAnalyzes the given object and call the preDestroy method. The object given will not be managed by bean manager.- Specified by:
preDestroyin interfaceInjectionManager- Parameters:
preDestroyMe- The object to preDestroy
-
shutdown
public void shutdown()Description copied from interface:InjectionManagerShuts down the entireInjectionManagerand the underlying DI provider.Shutdown phase is dedicated to make some final cleaning steps regarding underlying DI provider.
- Specified by:
shutdownin interfaceInjectionManager
-
isShutdown
public boolean isShutdown()Description copied from interface:InjectionManager- Specified by:
isShutdownin interfaceInjectionManager- Returns:
- Whether the
InjectionManagerhas been shutdown.
-
create
Description copied from interface:InjectionManagerCreates an object with the given class.The object created is not managed by the injection manager.
- Specified by:
createin interfaceInjectionManager- Parameters:
clazz- The non-null class to create this object from;- Returns:
- An instance of the object that has been created.
-
createAndInitialize
Description copied from interface:InjectionManagerCreates, injects and post-constructs an object with the given class. This is equivalent to calling thecreate-classmethod followed by theinject-classmethod followed by thepost-constructmethod.The object created is not managed by the injection manager.
- Specified by:
createAndInitializein interfaceInjectionManager- Parameters:
clazz- The non-null class to create this object from;- Returns:
- An instance of the object that has been created, injected and post constructed.
-
createForeignDescriptor
Description copied from interface:InjectionManagerCreates and registers the descriptor in the underlying DI provider and returnsForeignDescriptorthat is specific descriptor for the underlying DI provider.- Specified by:
createForeignDescriptorin interfaceInjectionManager- Parameters:
binding- jersey descriptor.- Returns:
- specific foreign descriptor of the underlying DI provider.
-
inject
Description copied from interface:InjectionManagerAnalyzes the given object and inject into its fields and methods. The object injected in this way will not be managed by HK2- Specified by:
injectin interfaceInjectionManager- Parameters:
injectMe- The object to be analyzed and injected into
-
inject
Description copied from interface:InjectionManagerThis will analyze the given object and inject into its fields and methods. The object injected in this way will not be managed by HK2- Specified by:
injectin interfaceInjectionManager- Parameters:
injectMe- The object to be analyzed and injected into
-