org.osesb.msgrouting.test.deployabletestpackage2
Class LoanProcessorPipelineStage
java.lang.Object
org.osesb.messagepipeline.PipelineStage
org.osesb.messagepipeline.builtinstages.DroolsRuleApplierPipelineStage
org.osesb.messagepipeline.builtinstages.DroolsRuleXMLApplierPipelineStage
org.osesb.msgrouting.test.deployabletestpackage2.LoanProcessorPipelineStage
public class LoanProcessorPipelineStage
- extends DroolsRuleXMLApplierPipelineStage
The DroolsRuleXMLApplierFlowControlPipelineStage named
SelectLoanProcessorMessagePipelineDroolsRuleFlowControlPipelineStage
in processloanapplication-message-pipeline-config.xml selects the loan
processor MessagePipeline to run based on the creditRating of the
LoanApplicationRequest.
Each loan processor MessagePipeline configures a single PipelineStage, which
is a LoanProcessorPipelineStage. LoanProcessorPipelineStage extends
DroolsRuleXMLApplierPipelineStage and approves or rejects the
loan application based on the loanAmount of the LoanApplicationRequest and the
loanThreshold property of the configured Drools rule.
The configured Drools rule, LoanProcessorPipelineStage.drl, is managed by the
the instance of the XMLRepository that is configured by
org/osesb/msgrouting/test/deployabletestpackage2/xml-repository/xml-filesystem-repository-test-config.xml.
The rule is:
if loanAmount <= loanThreshold, the loan is approved, otherwise the loan
is rejected.
LoanProcessorPipelineStage#runStage() processes a loanApplicationRequest
message as follows:
- runStage() invokes super.runStage(), which uses the configured XPath
expressions to extract Elements and Attributes from the XML as
org.osesb.utilities.xml.XMLNode(s) which are passed to the configured Drools
rule as facts.
- In this case, the configured Drools rule, LoanProcessorPipelineStage.drl,
is passed a XMLNode for the
<loanAmount> Element. The Drools rule is
configured with a property named 'loanThreshold'. The rule responds with
'accepted' as the loan approval status if loanAmount <= loanThreshold, otherwise
the rule returns 'rejected' as the loan approval status.
- LoanProcessorPipelineStage creates a loanApplicationResponse message,
which includes a
<loanDisposition> Element and a <loanProcesor>
element and then sets the MessagePipeline result to the loanApplicationResponse.
The <loanProcesor> element contains the name of the LoanProcessorPipelineStage
that processed the loan; it is used by ProcessLoanApplicationMessagePipelineUnitTest
to verify the LoanProcessorPipelineStage that processed the loanApplicationRequest.
|
Method Summary |
static void |
main(java.lang.String[] args)
main() For testing and sandboxing. |
boolean |
runStage(EAIMessage eaiMessage)
Run PipelineStage logic as follows:
runStage() invokes super.runStage(), which uses the configured XPath
expressions to extract Elements and Attributes from the XML as
org.osesb.utilities.xml.XMLNode(s) which are passed to the configured Drools
rule as facts.
In this case, the configured Drools rule, LoanProcessorPipelineStage.drl,
is passed a XMLNode for the <loanAmount> Element. |
| Methods inherited from class org.osesb.messagepipeline.PipelineStage |
commit, getMessagePipelineContext, getNextStage, getParentMessagePipeline, getPipelineStageConfiguration, getPreviousStage, handlePipelineException, handlePipelineException, logMessage, propagate, rollback, setNextStage, setOutputMessage, setPreviousStage, setResultMessage |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LoanProcessorPipelineStage
public LoanProcessorPipelineStage(MessagePipeline parentMessagePipeline,
PipelineStageConfiguration pipelineStageConfiguration)
throws java.lang.Exception
- Creates a new instance of LoanProcessorPipelineStage.
- 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 as follows:
- runStage() invokes super.runStage(), which uses the configured XPath
expressions to extract Elements and Attributes from the XML as
org.osesb.utilities.xml.XMLNode(s) which are passed to the configured Drools
rule as facts.
- In this case, the configured Drools rule, LoanProcessorPipelineStage.drl,
is passed a XMLNode for the
<loanAmount> Element. The Drools rule is
configured with a property named 'loanThreshold'. The rule responds with
'accepted' as the loan approval status if loanAmount <= loanThreshold, otherwise
the rule returns 'rejected' as the loan approval status.
- LoanProcessorPipelineStage creates a loanApplicationResponse message,
which includes a
<loanDisposition> Element and a <loanProcesor>
element and then sets the MessagePipeline result to the loanApplicationResponse.
The <loanProcesor> element contains the name of the LoanProcessorPipelineStage
that processed the loan. ; it is used by ProcessLoanApplicationMessagePipelineUnitTest
to verify the LoanProcessorPipelineStage that processed the loanApplicationRequest.
- Overrides:
runStage in class DroolsRuleApplierPipelineStage
- 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