org.glassfish.jersey.process.internal
Class Stages

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

public final class Stages
extends java.lang.Object

A stage-related collection of utility methods.

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

Method Summary
static LinearAcceptor.Builder acceptingChain(ChainableAcceptor rootStage)
          Start building a linear accepting chain.
static LinearAcceptor.Builder acceptingChain(com.google.common.base.Function<Request,Request> transformation)
          Start building a linear accepting chain.
static TreeAcceptor.Builder acceptingTree(com.google.common.base.Function<Request,Request> transformation)
          Start building a hierarchical accepting tree.
static LinearAcceptor asLinearAcceptor(Inflector<Request,Response> inflector)
          Creates a terminal LinearAcceptor that implements Inflecting interface and returns the provided Inflector instance when the Inflecting.inflector() method is called.
static TreeAcceptor asTreeAcceptor(Inflector<Request,Response> inflector)
          Creates a leaf-node TreeAcceptor that implements Inflecting interface and returns the provided Inflector instance when the Inflecting.inflector() method is called.
static
<DATA,RESULT>
com.google.common.base.Optional<Inflector<DATA,RESULT>>
extractInflector(java.lang.Object stage)
          (Optionally) extracts an inflector from a processing stage, provided the stage implements Inflecting interface.
static Responder.Builder respondingChain(com.google.common.base.Function<Response,Response> transformation)
          Start building a linear accepting chain.
static Pair<Request,java.util.Iterator<TreeAcceptor>> singletonTreeContinuation(Request request, TreeAcceptor nextAcceptor)
          Create a hierarchical continuation with the supplied request on the left side of the continuation and a singleton iterator containing the single next stage on the right side of the continuation.
static Pair<Request,com.google.common.base.Optional<LinearAcceptor>> terminalLinearContinuation(Request request)
          Create a terminal linear continuation with the supplied request on the left side of the continuation.
static Pair<Request,java.util.Iterator<TreeAcceptor>> terminalTreeContinuation(Request request)
          Create a terminal hierarchical continuation with the supplied request on the left side of the continuation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

terminalTreeContinuation

public static Pair<Request,java.util.Iterator<TreeAcceptor>> terminalTreeContinuation(Request request)
Create a terminal hierarchical continuation with the supplied request on the left side of the continuation.

Parameters:
request - transformed request to be returned as part of the terminal continuation.
Returns:
terminal hierarchical continuation.

singletonTreeContinuation

public static Pair<Request,java.util.Iterator<TreeAcceptor>> singletonTreeContinuation(Request request,
                                                                                       TreeAcceptor nextAcceptor)
Create a hierarchical continuation with the supplied request on the left side of the continuation and a singleton iterator containing the single next stage on the right side of the continuation.

Parameters:
request - transformed request to be returned as part of the terminal continuation.
nextAcceptor - next tree acceptor stage.
Returns:
singleton hierarchical continuation.

terminalLinearContinuation

public static Pair<Request,com.google.common.base.Optional<LinearAcceptor>> terminalLinearContinuation(Request request)
Create a terminal linear continuation with the supplied request on the left side of the continuation.

Parameters:
request - transformed request to be returned as part of the terminal continuation.
Returns:
terminal linear continuation.

asTreeAcceptor

public static TreeAcceptor asTreeAcceptor(Inflector<Request,Response> inflector)
Creates a leaf-node TreeAcceptor that implements Inflecting interface and returns the provided Inflector instance when the Inflecting.inflector() method is called. TreeAcceptor.apply(javax.ws.rs.core.Request) method of the created hierarchical acceptor returns the unchanged request and an empty continuation iterator.

Parameters:
inflector - a request to response transformation to be wrapped in an TreeAcceptor instance.
Returns:
an TreeAcceptor that wraps the supplied Inflector.

asLinearAcceptor

public static LinearAcceptor asLinearAcceptor(Inflector<Request,Response> inflector)
Creates a terminal LinearAcceptor that implements Inflecting interface and returns the provided Inflector instance when the Inflecting.inflector() method is called. LinearAcceptor.apply(javax.ws.rs.core.Request) method of the created linear acceptor returns the unchanged supplied request and a continuation referring to an absent next linear acceptor.

Parameters:
inflector - a request to response transformation to be wrapped in an TreeAcceptor instance.
Returns:
an TreeAcceptor that wraps the supplied Inflector.

extractInflector

public static <DATA,RESULT> com.google.common.base.Optional<Inflector<DATA,RESULT>> extractInflector(java.lang.Object stage)
(Optionally) extracts an inflector from a processing stage, provided the stage implements Inflecting interface. Otherwise method returns an absent inflector.

Type Parameters:
DATA - data type transformable by the stage and returned inflector.
RESULT - type of result produced by a successful inflector data transformation.
Parameters:
stage - a stage to extract the inflector from.
Returns:
extracted inflector, if present, absent inflector otherwise.

acceptingTree

public static TreeAcceptor.Builder acceptingTree(com.google.common.base.Function<Request,Request> transformation)
Start building a hierarchical accepting tree.

Parameters:
transformation - root transformation function.
Returns:
hierarchical accepting tree builder.

acceptingChain

public static LinearAcceptor.Builder acceptingChain(com.google.common.base.Function<Request,Request> transformation)
Start building a linear accepting chain.

Parameters:
transformation - root transformation function.
Returns:
linear accepting chain builder.

acceptingChain

public static LinearAcceptor.Builder acceptingChain(ChainableAcceptor rootStage)
Start building a linear accepting chain.

Parameters:
rootStage - root chainable linear stage.
Returns:
linear accepting chain builder.

respondingChain

public static Responder.Builder respondingChain(com.google.common.base.Function<Response,Response> transformation)
Start building a linear accepting chain.

Parameters:
transformation - root transformation function.
Returns:
linear accepting chain builder.


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