org.glassfish.jersey.server.spi
Interface ContainerProvider


@Contract
@ConstrainedTo(value=SERVER)
public interface ContainerProvider

Service-provider interface for creating container instances. If supported by the provider, a container instance of the requested Java type will be created.

The created container is responsible for listening on a communication chanel for new client requests, dispatching these requests to the registered Jersey application handler using the handler's ApplicationHandler.apply(org.glassfish.jersey.server.ContainerRequest) apply(requestContext)} method and sending the responses provided by the application back to the client.

A provider shall support a one-to-one mapping between a type that is not of the type Object. A provider may support more than one one-to-one mapping or a mapping of sub-types of a type (that is not of the type Object). A provider shall not conflict with other providers.

An implementation (a service-provider) identifies itself by registering a proper HK2 ContainterProvider contract binding in a custom HK2 binder configured in the Jersey application handler. Alternatively, the implementation can identify itself by placing a provider-configuration file (if not already present), org.glassfish.jersey.server.spi.ContainerProvider in the resource directory META-INF/services, and adding the fully qualified service-provider-class of the implementation in the file.

Author:
Paul Sandoz, Jakub Podlesak (jakub.podlesak at oracle.com), Marek Potociar (marek.potociar at oracle.com)

Method Summary
<T> T
createContainer(Class<T> type, ApplicationHandler appHandler)
          Create an container of a given type.
 

Method Detail

createContainer

<T> T createContainer(Class<T> type,
                      ApplicationHandler appHandler)
                  throws ProcessingException
Create an container of a given type.

The container provider SHOULD NOT initiate the web application. The container provider MAY modify the resource configuration.

Type Parameters:
T - the type of the container.
Parameters:
type - the type of the container.
appHandler - the Web application handler the container delegates to for the handling of HTTP requests.
Returns:
the container, otherwise null if the provider does not support the requested type.
Throws:
ProcessingException - if there is an error creating the container.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.