File ruleset execution sample details

You use Rule Designer to run this sample.

Running this sample

To run this sample:

  1. Deploy the RuleApp to a file system:
    1. 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 SUCCESSFUL

      Press F5 to refresh the workspace. The directory res_data has been created in the j2serulesession project. Navigate to see the deployed RuleApp.

  2. Run the ruleset:
    1. 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

Rebuilding this sample

To rebuild this sample:

  1. In the Rule Explorer, right click on j2serulession/build.xml and choose Run As/ 3 Ant build
  2. 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.