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

java.lang.Object
  extended by org.glassfish.jersey.process.internal.DefaultStagingContext<DATA>
Type Parameters:
DATA - supported transformable data type.
All Implemented Interfaces:
StagingContext<DATA>

public class DefaultStagingContext<DATA>
extends Object
implements StagingContext<DATA>

Default implementation of a staging context. The skeleton implementation provides support for tracking last stage applied to the data in the current staging context as well as default implementation of the beforeStage and afterStage callback methods.

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

Constructor Summary
protected DefaultStagingContext()
          Default protected constructor that sets the initial value of the last applied stage as well as actual state of the transformed data to absent.
protected DefaultStagingContext(Stage<DATA,?> lastStage, DATA data)
          Protected constructor that sets the initial value of the last applied stage as well as actual state of the transformed data to a custom stage supplied in the constructor parameter.
 
Method Summary
protected  void after(Stage<DATA,?> stage, DATA data)
          Protected callbacks to be overridden to provide custom implementation executed as part of the the after stage callback method.
 void afterStage(Stage<DATA,?> stage, DATA data)
          Callback method invoked after each stage in the continuation of stages is applied.
protected  void before(Stage<DATA,?> stage, DATA data)
          Protected callbacks to be overridden to provide custom implementation executed as part of the the before stage callback method.
 void beforeStage(Stage<DATA,?> stage, DATA data)
          Callback method invoked before each stage in the continuation of stages is applied.
 com.google.common.base.Optional<DATA> data()
          Get the processed data in the actual state in the current processing context.
 com.google.common.base.Optional<Stage<DATA,?>> lastStage()
          Get the last stage applied in the current staging context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultStagingContext

protected DefaultStagingContext()
Default protected constructor that sets the initial value of the last applied stage as well as actual state of the transformed data to absent.

Note that once the stage applying starts and the staging context callback methods are invoked, the initial value of the last applied stage as well as actual state of the transformed data change.


DefaultStagingContext

protected DefaultStagingContext(Stage<DATA,?> lastStage,
                                DATA data)
Protected constructor that sets the initial value of the last applied stage as well as actual state of the transformed data to a custom stage supplied in the constructor parameter.

Note that once the stage applying starts and the staging context callback methods are invoked, the initial value of the last applied stage as well as actual state of the transformed data change.

Parameters:
lastStage - stage to be initially used as the last applied stage. Passing null into the constructor will result in an absent initial last applied stage.
data - actual state of the transformed data to be set initially in the processing context.
Method Detail

beforeStage

public final void beforeStage(Stage<DATA,?> stage,
                              DATA data)
Description copied from interface: StagingContext
Callback method invoked before each stage in the continuation of stages is applied.

Specified by:
beforeStage in interface StagingContext<DATA>
Parameters:
stage - the stage to be applied.
data - the data to be transformed by the stage.

before

protected void before(Stage<DATA,?> stage,
                      DATA data)
Protected callbacks to be overridden to provide custom implementation executed as part of the the before stage callback method.

Parameters:
stage - the stage to be applied.
data - the data to be transformed by the stage.

afterStage

public final void afterStage(Stage<DATA,?> stage,
                             DATA data)
Description copied from interface: StagingContext
Callback method invoked after each stage in the continuation of stages is applied.

Specified by:
afterStage in interface StagingContext<DATA>
Parameters:
stage - the stage recently applied.
data - the stage transformation result.

after

protected void after(Stage<DATA,?> stage,
                     DATA data)
Protected callbacks to be overridden to provide custom implementation executed as part of the the after stage callback method.

Parameters:
stage - the stage previously applied.
data - the stage transformation result.

lastStage

public final com.google.common.base.Optional<Stage<DATA,?>> lastStage()
Description copied from interface: StagingContext
Get the last stage applied in the current staging context. The returned stage can be Optional.absent() in case no stage has been applied yet.

Specified by:
lastStage in interface StagingContext<DATA>
Returns:
last stage applied in the current processing context.

data

public final com.google.common.base.Optional<DATA> data()
Description copied from interface: StagingContext
Get the processed data in the actual state in the current processing context.

Specified by:
data in interface StagingContext<DATA>
Returns:
actual state of the processed data.


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