Package org.glassfish.jersey.spi
Interface ComponentProvider
- All Known Subinterfaces:
ComponentProvider
- All Known Implementing Classes:
CdiComponentProvider
,CdiServerComponentProvider
public interface ComponentProvider
Component provider interface to allow custom management of 3rd party
components life-cycle and dependency injection.
An implementation (a component-provider) identifies itself by placing a provider-configuration
file (if not already present),
org.glassfish.jersey.spi.ComponentProvider
in the resource directory META-INF/services, and adding the fully
qualified service-provider-class of the implementation in the file.
Jersey will not even try to inject component provider instances with Jersey artifacts.
The SPI providers should be designed so that no dependency injection is needed at the bind time phase.- Author:
- Jakub Podlesak
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Jersey will invoke this method before binding of each component class internally during initialization of it's injection manager.default 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.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.
-
Method Details
-
initialize
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. 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.- Parameters:
injectionManager
- an injection manager.
-
bind
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.- Parameters:
component
- 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
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.- 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
void done()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.
-