org.glassfish.jersey.server.spi
Interface ComponentProvider


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.server.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 (jakub.podlesak at oracle.com)

Method Summary
 boolean bind(Class<?> component, Set<Class<?>> providerContracts)
          Jersey will invoke this method before binding of each component class internally during initialization of it's HK2 service locator.
 void done()
          Jersey will invoke this method after all component classes have been bound.
 void initialize(org.glassfish.hk2.api.ServiceLocator locator)
          Initializes the component provider with a reference to a HK2 service locator instance, which will get used in the application to manage individual components.
 

Method Detail

initialize

void initialize(org.glassfish.hk2.api.ServiceLocator locator)
Initializes the component provider with a reference to a HK2 service locator instance, which will get used in the application to manage individual components. Providers should keep a reference to the HK2 service locator for later use. This method will be invoked prior to any bind method calls. The service locator parameter will not be fully initialized at the time of invocation and should be used as a reference only.

Parameters:
locator - an HK2 service locator.

bind

boolean bind(Class<?> component,
             Set<Class<?>> providerContracts)
Jersey will invoke this method before binding of each component class internally during initialization of it's HK2 service locator. 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

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.



Copyright © 2007-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.