Class CdiComponentProvider
java.lang.Object
org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider
- All Implemented Interfaces:
jakarta.enterprise.inject.spi.Extension
,ComponentProvider
public class CdiComponentProvider
extends Object
implements ComponentProvider, jakarta.enterprise.inject.spi.Extension
Jersey CDI integration implementation.
Implements
Jersey component provider
to serve CDI beans
obtained from the actual CDI bean manager.
To properly inject JAX-RS/Jersey managed beans into CDI, it also
serves as a CDI Extension
, that intercepts CDI injection targets.- Author:
- Jakub Podlesak
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Auxiliary annotation for mocked beans used to cover Jersey/HK2 injected injection points. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name to be used when binding CDI injectee skipping class analyzer to HK2 service injection manager. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addHK2DepenendencyCheck
(Predicate<Class<?>> predicate) Add a predicate to test HK2 dependency to create a CDI bridge bean to HK2 for it.boolean
Jersey will invoke this method before binding of each component class internally during initialization of it's injection manager.boolean
bind
(Class<?> component, ContractProvider contractProvider) Jersey will invoke this method before binding of each component class internally during initialization of it's injection manager.void
done()
Jersey will invoke this method after all component classes have been bound.org.glassfish.jersey.internal.inject.InjectionManager
Gets you effective injection manager.void
initialize
(org.glassfish.jersey.internal.inject.InjectionManager injectionManager) Initializes the component provider with a reference to a injection manager instance, which will get used in the application to manage individual components.void
processAnnotatedType
(jakarta.enterprise.inject.spi.ProcessAnnotatedType processAnnotatedType)
-
Field Details
-
CDI_CLASS_ANALYZER
Name to be used when binding CDI injectee skipping class analyzer to HK2 service injection manager.- See Also:
-
-
Constructor Details
-
CdiComponentProvider
public CdiComponentProvider()
-
-
Method Details
-
initialize
public void initialize(org.glassfish.jersey.internal.inject.InjectionManager injectionManager) Description copied from interface:ComponentProvider
Initializes the component provider with a reference to a injection manager instance, which will get used in the application to manage individual components. Providers should keep a reference to the injection manager for later use. This method will be invoked prior to any bind method calls. The injection manager parameter will not be fully initialized at the time of invocation and should be used as a reference only.- Specified by:
initialize
in interfaceComponentProvider
- Parameters:
injectionManager
- an injection manager.
-
bind
Description copied from interface:ComponentProvider
Jersey will invoke this method before binding of each component class internally during initialization of it's injection manager. If the component provider wants to bind the component class itself, it must do so and return true. In that case, Jersey will not bind the component and rely on the component provider in this regard.- Specified by:
bind
in interfaceComponentProvider
- Parameters:
clazz
- a component (resource/provider) class.providerContracts
- provider contracts implemented by given component.- Returns:
- true if the component class has been bound by the provider, false otherwise
-
bind
Description copied from interface:ComponentProvider
Jersey will invoke this method before binding of each component class internally during initialization of it's injection manager. If the component provider wants to bind the component class itself, it must do so and return true. In that case, Jersey will not bind the component and rely on the component provider in this regard.- Specified by:
bind
in interfaceComponentProvider
- Parameters:
component
- a component (resource/provider) class.contractProvider
- optional registeredContractProvider
of the component.- Returns:
- true if the component class has been bound by the provider, false otherwise
-
done
public void done()Description copied from interface:ComponentProvider
Jersey will invoke this method after all component classes have been bound. If the component provider wants to do some actions after it has seen all component classes registered with the application, this is the right place for the corresponding code.- Specified by:
done
in interfaceComponentProvider
-
processAnnotatedType
public void processAnnotatedType(jakarta.enterprise.inject.spi.ProcessAnnotatedType processAnnotatedType) -
getEffectiveInjectionManager
public org.glassfish.jersey.internal.inject.InjectionManager getEffectiveInjectionManager()Gets you effective injection manager. Note: Do NOT lower the visibility of this method. CDI proxies need at least this visibility.- Returns:
- HK2 injection manager.
-
addHK2DepenendencyCheck
Add a predicate to test HK2 dependency to create a CDI bridge bean to HK2 for it.- Parameters:
predicate
- to test whether given class is a HK2 dependency.
-