org.glassfish.jersey.process.internal
Class RequestInvoker

java.lang.Object
  extended by org.glassfish.jersey.process.internal.RequestInvoker

public class RequestInvoker
extends java.lang.Object

Request invoker is the main request to response processing entry point. It invokes requests and returns a listenable response future.

Request invoker uses an (injectable) request processor to run each invoked request through the (injected) request processing stages (acceptors until a terminal request processing stage referencing an Inflector<Request, Response> is reached. The inflector referenced by the terminal request processing stage is then wrapped into a suspendable inflector which is subsequently invoked. Once a response from the inflector is available, it is processed by a response processor before it is made available in the response future returned by the request invoker. If a response callback is supplied, it is invoked at the end of the response processing chain.

Request and response processing tasks are handled by a pair of dedicated customizable executors, one for request and the other one for response processing. By default, the request processing is executed on the caller thread. If the request processing is not suspended in the inflector, the response processing is by default executed synchronously on the caller thread too. In case the request processing is suspended, the response processing is resumed in the thread executing the code that resumed the response processing.

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

Nested Class Summary
static class RequestInvoker.Builder
          Injection-enabled RequestInvoker instance builder.
 
Method Summary
 com.google.common.util.concurrent.ListenableFuture<Response> apply(Request request)
          Transform request data of a given type into a response result of the different type.
 com.google.common.util.concurrent.ListenableFuture<Response> apply(Request request, InvocationCallback callback)
          Transform request data of a given type into a response result of the different type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

apply

public com.google.common.util.concurrent.ListenableFuture<Response> apply(Request request)
Transform request data of a given type into a response result of the different type.

Parameters:
request - request data to be transformed into a response result.
Returns:
future response.

apply

public com.google.common.util.concurrent.ListenableFuture<Response> apply(Request request,
                                                                          InvocationCallback callback)
Transform request data of a given type into a response result of the different type.

After the result is produced the provided result callback is invoked. The result callback can be invoked on a different thread but still in the same request invocation context.

Parameters:
request - request data to be transformed into a response result.
callback - result callback called when the request transformation is done. Must not be null.
Returns:
future response.


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