File ruleset execution sample details
You use Rule Designer to run this sample.
Running this sample
To run this sample:
- Deploy the RuleApp to a file system:
- In the Rule Explorer, right click j2serulession/build.xml and choose
Run As/ 2 Ant build to deploy the RuleApp on files. The console displays the
output trace of the res-write-file Ant task. It ends as
follows:
[res-write-file] /test_deployment/1.0 -> /test_deployment/1.0: Element added. [res-write-file] /test_deployment/1.0/loan_validation_production/1.0 -> /test_deployment/1.0/loan_validation_production/1.0: Element added. [res-write-file] /test_deployment/1.0/loan_validation_with_score_and_grade/1.0 -> /test_deployment/1.0/loan_validation_with_score_and_grade/1.0: Element added. [res-write-file] Write succeeded. BUILD SUCCESSFULPress F5 to refresh the workspace. The directory res_data has been created in the j2serulesession project. Navigate to see the deployed RuleApp.
- In the Rule Explorer, right click j2serulession/build.xml and choose
Run As/ 2 Ant build to deploy the RuleApp on files. The console displays the
output trace of the res-write-file Ant task. It ends as
follows:
- Run the ruleset:
- In the Rule Explorer, right click j2serulession/Ruleset execution.launch
and choose Run As/ 1 Ruleset execution to run the ruleset. The console displays
the output of the run. It ends as
follows:
Report: Valid data true Approved false - Rate 0.055 - Monthly repayment 2,325.65 - Message Average risk loan Too big Debt/Income ratio: 1.40 We are sorry. Your loan has not been approved
- In the Rule Explorer, right click j2serulession/Ruleset execution.launch
and choose Run As/ 1 Ruleset execution to run the ruleset. The console displays
the output of the run. It ends as
follows:
Rebuilding this sample
To rebuild this sample:
- In the Rule Explorer, right click on j2serulession/build.xml and choose Run As/ 3 Ant build
- Select only the clean target and click Run. This operation removes the deployed RuleApp from the files.
How this sample works
This sample demonstrates a stand-alone Java™ SE execution stack. The management stack is not deployed, so you cannot view the deployed RuleApps in the Rule Execution Server console.
Source files
This sample is in the <InstallDir>/executionserver/samples/j2serulesession/src/j2serulesession directory.
The execution code is in the j2serulession project that you already imported in Rule Designer. Switch to the Java perspective at the execution code:
- The function testRulesetWithSession in src/j2serulession/ExecuteRuleset.java runs a ruleset deployed in J2SE mode.
- The function init in src/j2serulession/ExecuteRuleset.java creates a session factory and a session.
- The j2serulesession/build.xml file contains the tasks to deploy the RuleApp in J2SE mode. It uses the RES task res-write-file.