org.glassfish.jersey.process.internal
Class ResponseProcessor<DATA>

java.lang.Object
  extended by org.glassfish.jersey.process.internal.ResponseProcessor<DATA>
Type Parameters:
DATA - processed data type.
All Implemented Interfaces:
Runnable

public abstract class ResponseProcessor<DATA>
extends Object
implements Runnable

Processes result of the request transformation (successful or not). The response processor also represents the ultimate future request-to-response transformation result.

A response processor is invoked when the request-to-response transformation processing is finished. When invoked, the response processor retrieves the transformation result. If the transformation was successful and a response instance is returned, the response processor runs the response instance through the chain of registered response filters and returns a result once finished. In case the request transformation finished with an exception, the response processor tries to map the exception to a response using the registered exception mappers and, if successful, runs the mapped response instance through the chain of registered response filters and returns a result once finished. In case the exception was not mapped to a response, the exception is presented as the ultimate request-to-response transformation result.

Author:
Marek Potociar (marek.potociar at oracle.com)

Nested Class Summary
static interface ResponseProcessor.Builder<DATA>
          Response processor factory.
static interface ResponseProcessor.RespondingContext<DATA>
          Injectable context that can be used during the data processing for registering response processing functions that will be invoked during the response processing.
 
Constructor Summary
protected ResponseProcessor(InvocationCallback<DATA> callback, Future<DATA> inflectedResponse, com.google.common.util.concurrent.SettableFuture<DATA> processedResponse, javax.inject.Provider<ResponseProcessor.RespondingContext<DATA>> respondingCtxProvider, RequestScope.Instance scopeInstance, RequestScope requestScope, javax.inject.Provider<ExceptionMappers> exceptionMappersProvider)
          Create new response processor for a given request / response message exchange.
 
Method Summary
protected abstract  DATA convertResponse(Response exceptionResponse)
          Convert an exception-mapped JAX-RS response to supported processing data type.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResponseProcessor

protected ResponseProcessor(InvocationCallback<DATA> callback,
                            Future<DATA> inflectedResponse,
                            com.google.common.util.concurrent.SettableFuture<DATA> processedResponse,
                            javax.inject.Provider<ResponseProcessor.RespondingContext<DATA>> respondingCtxProvider,
                            RequestScope.Instance scopeInstance,
                            RequestScope requestScope,
                            javax.inject.Provider<ExceptionMappers> exceptionMappersProvider)
Create new response processor for a given request / response message exchange.

Parameters:
callback - the invocation callback to be invoked once the response processing has finished.
inflectedResponse - inflected response data future.
processedResponse - settable future that will be used to set the response processing result.
respondingCtxProvider - responding context provider.
scopeInstance - the instance of the request scope this processor belongs to.
requestScope - Jersey request scope.
exceptionMappersProvider - exception mappers provide.
Method Detail

run

public void run()
Specified by:
run in interface Runnable

convertResponse

protected abstract DATA convertResponse(Response exceptionResponse)
Convert an exception-mapped JAX-RS response to supported processing data type.

Parameters:
exceptionResponse - a processing exception mapped to a JAX-RS response.
Returns:
JAX-RS exception-mapped response transformed to supported processing data type.


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