atg.service.pipeline
Class PipelineChain

java.lang.Object
  extended by atg.service.pipeline.PipelineChain
All Implemented Interfaces:
java.io.Serializable

public class PipelineChain
extends java.lang.Object
implements java.io.Serializable

This class is responsible for maintaining the list of processors to be executed in series. The chain keeps track of the transactional information and starts, stops, or suspends transactions as necessary. See the JTA specification for more information. The PipelineChain consists of PipelineProcessors whose return code values determine which processor if any is called next in the execution stream.

See Also:
PipelineProcessor, Serialized Form

Field Summary
static java.lang.String CLASS_VERSION
           
static int TX_MANDATORY
           
static java.lang.String TX_MANDATORY_STR
           
static int TX_NOT_SUPPORTED
           
static java.lang.String TX_NOT_SUPPORTED_STR
           
static int TX_REQUIRED
           
static java.lang.String TX_REQUIRED_STR
           
static int TX_REQUIRES_NEW
           
static java.lang.String TX_REQUIRES_NEW_STR
           
static int TX_SUPPORTS
           
static java.lang.String TX_SUPPORTS_STR
           
 
Method Summary
 void addTransition(PipelineLink pFromLink, int pRetCode, PipelineLink pToLink)
          Adds a transition from aFromLink to aToLink.
 void addTransition(PipelineLink pFromLink, int pRetCode, PipelineLink pToLink, boolean pRemoveExisting)
          Adds a transition from aFromLink to aToLink.
protected  void cancelChainTransaction()
          Called by the PipelineChain if an error occurs during the execution of a pipeline chain.
protected  void cancelLinkTransaction(PipelineLink pLink)
          Called by the PipelineChain if an error occurs during the execution of a pipeline chain.
 void clearHeadLink()
          Clears the head link from this chain and essentially resets the chain to have no links or transitions in it.
 PipelineLink createLink(java.lang.String pLinkId, PipelineProcessor pProc, PipelineLink pFromLink, int pRetCode, atg.service.pipeline.ProcessorConfiguration pProcConfig)
          Creates a PipelineLink object with the name aLinkId and the PipelineProcessor aProc.
 PipelineLink getHeadLink()
          Returns the first link in the PipelineChain.
 java.lang.String getId()
          Returns the chainId.
 PipelineLink getLinkById(java.lang.String pLinkId)
          Given a LinkId this method will search for it in a chain.
 ApplicationLogging getLogging()
          Returns the logging
 int getTransactionMode()
          Returns the default transaction mode of the chain.
protected  PipelineLink instantiatePipelineLink(java.lang.String pLinkId)
          This method should be overridden by subclasses.
protected  void postChainTransaction()
          Called by the PipelineChain after calling runProcess() to cleanup any transaction data as a result of the execution of the pipeline.
protected  void postLinkTransaction(PipelineLink pLink)
          Called by the PipelineChain after calling runProcess() to cleanup any transaction data as a result of the execution of the pipeline.
protected  void preChainTransaction()
          Called by the PipelineChain before calling runProcess() to setup any transaction data or structures for the execution of the processor.
protected  void preLinkTransaction(PipelineLink pLink)
          Called by the PipelineChain before calling runProcess() to setup any transaction data or structures for the execution of the processor.
 void removeTransition(PipelineLink pFromLink, int pRetCode)
          Removes the transition in aFromLink with the return code aRetCode.
 void removeTransition(PipelineLink pFromLink, PipelineLink pToLink)
          Remove the transition from aFromLink to aToLink.
protected  PipelineResult runProcess(java.lang.Object pParam)
          This method runs the chain.
 PipelineLink setHeadLink(java.lang.String pLinkId, PipelineProcessor pProc, atg.service.pipeline.ProcessorConfiguration pProcConfig)
          Sets the first link in the PipelineChain to aLink.
 void setLogging(ApplicationLogging pLogging)
          Sets the logging
 void setTransactionMode(int pMode)
          Sets the default transaction mode of the chain.
static int stringToTransactionMode(java.lang.String pMode)
          Given a String representation of a transaction mode, returns the corresponding transaction mode
static java.lang.String transactionModeToString(int pMode)
          Given a transaction mode, returns a String representation of it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

TX_REQUIRED

public static final int TX_REQUIRED
See Also:
Constant Field Values

TX_REQUIRES_NEW

public static final int TX_REQUIRES_NEW
See Also:
Constant Field Values

TX_SUPPORTS

public static final int TX_SUPPORTS
See Also:
Constant Field Values

TX_NOT_SUPPORTED

public static final int TX_NOT_SUPPORTED
See Also:
Constant Field Values

TX_MANDATORY

public static final int TX_MANDATORY
See Also:
Constant Field Values

TX_REQUIRED_STR

public static final java.lang.String TX_REQUIRED_STR
See Also:
Constant Field Values

TX_REQUIRES_NEW_STR

public static final java.lang.String TX_REQUIRES_NEW_STR
See Also:
Constant Field Values

TX_SUPPORTS_STR

public static final java.lang.String TX_SUPPORTS_STR
See Also:
Constant Field Values

TX_NOT_SUPPORTED_STR

public static final java.lang.String TX_NOT_SUPPORTED_STR
See Also:
Constant Field Values

TX_MANDATORY_STR

public static final java.lang.String TX_MANDATORY_STR
See Also:
Constant Field Values
Method Detail

instantiatePipelineLink

protected PipelineLink instantiatePipelineLink(java.lang.String pLinkId)
This method should be overridden by subclasses. It should return a new instance of a PipelineLink object or subclass of it which pertains to the instance of the PipelineChain.


getId

public final java.lang.String getId()
Returns the chainId. This is the name of the PipelineChain object.


getLogging

public ApplicationLogging getLogging()
Returns the logging


setLogging

public void setLogging(ApplicationLogging pLogging)
Sets the logging


getHeadLink

public PipelineLink getHeadLink()
Returns the first link in the PipelineChain.


setHeadLink

public PipelineLink setHeadLink(java.lang.String pLinkId,
                                PipelineProcessor pProc,
                                atg.service.pipeline.ProcessorConfiguration pProcConfig)
                         throws CreateLinkException,
                                LockChainException
Sets the first link in the PipelineChain to aLink. If aProc is null this method will remove the head link and set it to null (this essentially clears the chain). The caller must have a lock on this chain to call this method.

Throws:
CreateLinkException
LockChainException

clearHeadLink

public void clearHeadLink()
                   throws LockChainException
Clears the head link from this chain and essentially resets the chain to have no links or transitions in it. The caller must have a lock on this chain to call this method.

Throws:
LockChainException

setTransactionMode

public void setTransactionMode(int pMode)
                        throws LockChainException
Sets the default transaction mode of the chain. This means that all the link's transaction modes in the chain will default to the given mode. The caller must have a lock on this chain to call this method.

Throws:
LockChainException

getTransactionMode

public int getTransactionMode()
Returns the default transaction mode of the chain.


runProcess

protected PipelineResult runProcess(java.lang.Object pParam)
                             throws RunProcessException
This method runs the chain. The parameter is user data that is meant to be used by the PipelineProcessors. This method must be package protected because it should only be called from the PipelineManager.

Throws:
RunProcessException

getLinkById

public PipelineLink getLinkById(java.lang.String pLinkId)
Given a LinkId this method will search for it in a chain. This method is fairly expensive to call. Returns null if no link with the given name is found.


createLink

public PipelineLink createLink(java.lang.String pLinkId,
                               PipelineProcessor pProc,
                               PipelineLink pFromLink,
                               int pRetCode,
                               atg.service.pipeline.ProcessorConfiguration pProcConfig)
                        throws CreateLinkException,
                               TransitionException,
                               LockChainException
Creates a PipelineLink object with the name aLinkId and the PipelineProcessor aProc. It then adds a reference of this link to the return code/link mapping in aFromLink and maps it to aRetCode. If the return code is already mapped in aFromLink, then a CreateLinkException will be thrown. To add a new head link, you must pass null for aFromLink (aRetCode is then ignored) or call setHeadLink().

Throws:
CreateLinkException
TransitionException
LockChainException

addTransition

public void addTransition(PipelineLink pFromLink,
                          int pRetCode,
                          PipelineLink pToLink)
                   throws TransitionException,
                          LockChainException
Adds a transition from aFromLink to aToLink. aRetCode is the return code that is mapped to the aToLink inside aFromLink. If aRetCode is already mapped in aFromLink, then a TransitionException is thrown.

Throws:
TransitionException
LockChainException

addTransition

public void addTransition(PipelineLink pFromLink,
                          int pRetCode,
                          PipelineLink pToLink,
                          boolean pRemoveExisting)
                   throws TransitionException,
                          LockChainException
Adds a transition from aFromLink to aToLink. aRetCode is the return code that is mapped to the aToLink inside aFromLink. If pRemoveExisting is true then if a return code is mapped which equals pRetCode, then it is replaced with pToLink. If pRemoveExisting is false and pRetCode is already mapped, then a TransitionException is thrown.

Throws:
TransitionException
LockChainException

removeTransition

public void removeTransition(PipelineLink pFromLink,
                             int pRetCode)
                      throws TransitionException,
                             LockChainException
Removes the transition in aFromLink with the return code aRetCode. If a aRetCode is not mapped in aFromLink then a TransitionException is thrown.

Throws:
TransitionException
LockChainException

removeTransition

public void removeTransition(PipelineLink pFromLink,
                             PipelineLink pToLink)
                      throws TransitionException,
                             LockChainException
Remove the transition from aFromLink to aToLink. If there is no transition then a TransitionException will be thrown. Note that this method is much more expensive to call compared to removeTransition(PipelineLink, int).

Throws:
TransitionException
LockChainException

preChainTransaction

protected void preChainTransaction()
                            throws RunProcessException
Called by the PipelineChain before calling runProcess() to setup any transaction data or structures for the execution of the processor.

Throws:
RunProcessException

postChainTransaction

protected void postChainTransaction()
                             throws RunProcessException
Called by the PipelineChain after calling runProcess() to cleanup any transaction data as a result of the execution of the pipeline.

Throws:
RunProcessException

cancelChainTransaction

protected void cancelChainTransaction()
                               throws RunProcessException
Called by the PipelineChain if an error occurs during the execution of a pipeline chain.

Throws:
RunProcessException

preLinkTransaction

protected void preLinkTransaction(PipelineLink pLink)
                           throws RunProcessException
Called by the PipelineChain before calling runProcess() to setup any transaction data or structures for the execution of the processor.

Throws:
RunProcessException

postLinkTransaction

protected void postLinkTransaction(PipelineLink pLink)
                            throws RunProcessException
Called by the PipelineChain after calling runProcess() to cleanup any transaction data as a result of the execution of the pipeline.

Throws:
RunProcessException

cancelLinkTransaction

protected void cancelLinkTransaction(PipelineLink pLink)
                              throws RunProcessException
Called by the PipelineChain if an error occurs during the execution of a pipeline chain.

Throws:
RunProcessException

transactionModeToString

public static java.lang.String transactionModeToString(int pMode)
Given a transaction mode, returns a String representation of it

Returns:
a string representation of the transaction mode or null if pMode is not a valid transaction mode

stringToTransactionMode

public static int stringToTransactionMode(java.lang.String pMode)
Given a String representation of a transaction mode, returns the corresponding transaction mode

Returns:
the transaction mode or -1 if pMode is not a valid mode