org.osesb.messagepipeline.test.builtinstagesunittest
Class ExtractCDElementValuesPipelineStage
java.lang.Object
org.osesb.messagepipeline.PipelineStage
org.osesb.messagepipeline.builtinstages.XMLNodeExtractorPipelineStage
org.osesb.messagepipeline.test.builtinstagesunittest.ExtractCDElementValuesPipelineStage
public class ExtractCDElementValuesPipelineStage
- extends XMLNodeExtractorPipelineStage
ExtractCDElementValuesPipelineStage extends XMLNodeExtractorPipelineStage to extract the
messageID attribute and the <title> and <price> elements and place their values in a
MessagePipelineContext variable named stageName.sqlStatementName.sqlParameters as an Object[].
stageName is the name of the subsequent DatabaseUpdatePipelineStage and sqlStatementName is the
name of the SQLStatement in the DatabaseUpdatePipelineStage.
The sqlParameters are used by the DatabaseUpdatePipelineStage as input to the parameterized update
of the 'CDELEMENTS' table in the JDBCTEST tables.
- Since:
- Version .9
|
Method Summary |
static void |
main(java.lang.String[] args)
main() For testing and sandboxing. |
boolean |
runStage(EAIMessage eaiMessage)
Run PipelineStage logic. |
| Methods inherited from class org.osesb.messagepipeline.PipelineStage |
beingDroppedFromPool, commit, getMessagePipelineContext, getNextStage, getParentMessagePipeline, getPipelineStageConfiguration, getPreviousStage, handlePipelineException, handlePipelineException, logMessage, propagate, rollback, setNextStage, setOutputMessage, setPreviousStage, setResultMessage, stageProcessingComplete, stageProcessingStarting |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExtractCDElementValuesPipelineStage
public ExtractCDElementValuesPipelineStage(MessagePipeline parentMessagePipeline,
PipelineStageConfiguration pipelineStageConfiguration)
throws java.lang.Exception
- Creates a new instance of ExtractCDElementValuesPipelineStage.
- Parameters:
parentMessagePipeline - The MessagePipeline that constructed
this PipelineStage.pipelineStageConfiguration - A PipelineStageConfiguration for
this PipelineStage.
- Throws:
java.lang.Exception - if constructed with a null parentMessagePipeline or a
null pipelineStageConfiguration.
runStage
public boolean runStage(EAIMessage eaiMessage)
throws PipelineStageException
- Run PipelineStage logic.
The runStage() method expects an IXMLMessage with XML text as the payload.
ExtractCDElementValuesPipelineStage is configured with a stageConfiguration that is a
StandardPipelineStageConfiguration that includes a XPathExpressionListConfiguration with
one or more xpathExpressions, which are applied to the XML text of the EAIXMLMessage.
runStage() invokes it's ancestor to apply the xpathExpressions and extract the target Nodes.
The ancestor method sets a MessagePipelineContext variable to the extracted Nodes. The
variable is a Map named "stageName.extractedNodeMap", where 'stageName' is the name of the
PipelineStage. The Map uses the name of the xpathExpression as the key and a Node[]
of extracted Nodes as the value.
MessagePipeline invokes the runStage() method on each PipelineStage in the order they
appear in the MessagePipelineConfiguration. More specifically, the MessagePipeline
invokes the following PipelineStage methods:
- stageProcessingStarting(): The PipelineStage should allocate resources needed by runStage() in this method.
- runStage()(): Main PipelineStage logic. To propagate the results of runStage() to the next stage, a
PipelineStage invokes setOutputMessage() and/or propagate() with the EAIMessage to be passed to the next stage.
setOutputMessage() is usually one of the last statements in runStage(), but propagate() can be invoked
at any point in the runStage() method. See setOutputMessage() and propagate().
- commit(): If a PipeleineStageException is not thrown, then commit() is invoked to commit outstanding transactions.
The 'transactionScope' PipelineStageConfiguration property controls how the commit() and rollback() methods are
invoked. See the getTransactionScope() method in PipelineStageConfiguration for details.
- rollback(): If a PipeleineStageException is thrown, then rollback() is invoked to rollback outstanding
transactions. The 'transactionScope' PipelineStageConfiguration property controls how the commit() and
rollback() methods are invoked. See the getTransactionScope() method in PipelineStageConfiguration for details.
- stageProcessingComplete(): PipelineStage should release resources in this method. The MessagePipeline invokes
stageProcessingComplete() after all PipelineStage transactions are committed or rolled back.
If a PipelineStage's runStage() method returns false, then pipeline processing
terminates with that stage and subsequent stages are not run. However, returning false
does not indicate an error to the MessagePipeline. Returning false from runStage() indicates
that pipeline processing completed normally before the end of the pipeline
was reached.
If a PipelineStage's runStage() method returns true, then the MessagePipeline runs the
next stage.
When pipeline processing ends normally, without throwing a PipelineStageException, the
MessagePipeline will commit outstanding transactions beginning with the first
PipelineStage. The 'transactionScope' PipelineStageConfiguration property controls how the
commit() and rollback() PipelineStage methods are invoked. See the getTransactionScope()
method in PipelineStageConfiguration for details around configuring 'transactionScope'
for PipelineStages.
If a PipelineStage's runStage() method throws a PipelineStageException, then pipeline
processing terminates with that stage and subsequent stages are not run.
When pipeline processing ends with a PipelineStageException, the MessagePipeline will
roll back outstanding transactions beginning with the PipelineStage that threw the Exception.
The 'transactionScope' PipelineStageConfiguration property controls how the commit() and
rollback() PipelineStage methods are invoked. See the getTransactionScope() method in
PipelineStageConfiguration for details around configuring 'transactionScope' for PipelineStages.
- Overrides:
runStage in class XMLNodeExtractorPipelineStage
- Parameters:
eaiMessage - The EAI message, which is the output of the last PipeLineStage that invoked
setOutputMessage(), or, if this is the first PiplelineStage, then this is the EAIMessage
that the MessagePipeline was invoked with.
- Returns:
- true to continue pipeline processing or false to terminate pipeline processing.
- Throws:
a - PipelineStageException if any errors occur.
PipelineStageException
main
public static void main(java.lang.String[] args)
- main() For testing and sandboxing.
- Parameters:
args - commandline arguments