org.glassfish.jersey.server
Class ApplicationHandler

java.lang.Object
  extended by org.glassfish.jersey.server.ApplicationHandler

public final class ApplicationHandler
extends Object

Jersey server-side application handler.

Container implementations use the ApplicationHandler API to process requests by invoking the handle(requestContext) method on a configured application handler instance.

ApplicationHandler provides two implementations of config that can be injected into the application classes. The first is resource config which implements Configuration itself and is configured by the user. The resource config is not modified by this application handler so the future reloads of the application is not disrupted by providers found on a classpath. This config can be injected only as ResourceConfig or Application. The second one can be injected into the Configuration parameters / fields and contains info about all the properties / provider classes / provider instances from the resource config and also about all the providers found during processing classes registered under server properties. After the application handler is initialized both configurations are marked as read-only.

Author:
Pavel Bucek (pavel.bucek at oracle.com), Jakub Podlesak (jakub.podlesak at oracle.com), Marek Potociar (marek.potociar at oracle.com), Libor Kramolis (libor.kramolis at oracle.com)
See Also:
ResourceConfig, Configuration, ContainerProvider

Constructor Summary
ApplicationHandler()
          Create a new Jersey application handler using a default configuration.
ApplicationHandler(javax.ws.rs.core.Application application)
          Create a new Jersey server-side application handler configured by an instance of a JAX-RS Application sub-class.
ApplicationHandler(javax.ws.rs.core.Application application, org.glassfish.hk2.utilities.Binder customBinder)
          Create a new Jersey server-side application handler configured by an instance of a ResourceConfig and a custom Binder.
ApplicationHandler(Class<? extends javax.ws.rs.core.Application> jaxrsApplicationClass)
          Create a new Jersey server-side application handler configured by a JAX-RS Application (sub-)class.
 
Method Summary
 Future<ContainerResponse> apply(ContainerRequest requestContext)
          Invokes a request and returns the response future.
 Future<ContainerResponse> apply(ContainerRequest request, OutputStream outputStream)
          Invokes a request and returns the response future.
 ResourceConfig getConfiguration()
          Get the application configuration.
 org.glassfish.hk2.api.ServiceLocator getServiceLocator()
          Returns ServiceLocator relevant to current application.
 void handle(ContainerRequest requestContext)
          The main request/response processing entry point for Jersey container implementations.
 void registerAdditionalBinders(Iterable<org.glassfish.hk2.utilities.Binder> binders)
          Registers HK2 binders into the HK2 service register.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationHandler

public ApplicationHandler()
Create a new Jersey application handler using a default configuration.


ApplicationHandler

public ApplicationHandler(Class<? extends javax.ws.rs.core.Application> jaxrsApplicationClass)
Create a new Jersey server-side application handler configured by a JAX-RS Application (sub-)class.

Parameters:
jaxrsApplicationClass - JAX-RS Application (sub-)class that will be instantiated and used to configure the new Jersey application handler.

ApplicationHandler

public ApplicationHandler(javax.ws.rs.core.Application application)
Create a new Jersey server-side application handler configured by an instance of a JAX-RS Application sub-class.

Parameters:
application - an instance of a JAX-RS Application (sub-)class that will be used to configure the new Jersey application handler.

ApplicationHandler

public ApplicationHandler(javax.ws.rs.core.Application application,
                          org.glassfish.hk2.utilities.Binder customBinder)
Create a new Jersey server-side application handler configured by an instance of a ResourceConfig and a custom Binder.

Parameters:
application - an instance of a JAX-RS Application (sub-)class that will be used to configure the new Jersey application handler.
customBinder - additional custom bindings used during ServiceLocator creation
Method Detail

registerAdditionalBinders

public void registerAdditionalBinders(Iterable<org.glassfish.hk2.utilities.Binder> binders)
Registers HK2 binders into the HK2 service register.

Parameters:
binders - binders to be registered.

apply

public Future<ContainerResponse> apply(ContainerRequest requestContext)
Invokes a request and returns the response future.

Parameters:
requestContext - request data.
Returns:
response future.

apply

public Future<ContainerResponse> apply(ContainerRequest request,
                                       OutputStream outputStream)
Invokes a request and returns the response future.

Parameters:
request - request data.
outputStream - response output stream.
Returns:
response future.

handle

public void handle(ContainerRequest requestContext)
The main request/response processing entry point for Jersey container implementations.

The method invokes the request processing of the provided container request context and uses the container response writer to suspend & resume the processing as well as write the response back to the container.

The the security context stored in the container request context is bound as an injectable instance in the scope of the processed request context. Also, any custom scope injections are initialized in the current request scope.

Parameters:
requestContext - container request context of the current request.

getServiceLocator

public org.glassfish.hk2.api.ServiceLocator getServiceLocator()
Returns ServiceLocator relevant to current application.

Returns:
ServiceLocator instance.

getConfiguration

public ResourceConfig getConfiguration()
Get the application configuration.

Returns:
application configuration.


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