Code generators and client execution code

Rule Designer provides code generators in client projects to execute a specified ruleset.

After you have defined and developed business rules, the next step is to create a client application. The client application must call Rule Execution Server and locate the ruleset that you deployed. To call a deployed ruleset, you must use the public API to start a rule session from your client application. A client project is a predefined project for Eclipse that contains execution code to call rulesets that are contained in a RuleApp on Rule Execution Server. These clients can be Java™ applets running in a web browser or Java technology-based programs. You choose the code generator that best matches your needs.

If the provided generators do not match your needs when your RuleApp is deployed on both test and production platforms, you can customize a generator or write the execution code in your own client project using the appropriate rule session factory.

Code generation templates

Code generators are provided for simple Java models (POJO). The following table lists the code generation templates that you can use to integrate the calling code into your application.

Table 1. Code generation templates. Table shows code generators.
Code generator Target users Purpose
POJO generator For Java EE experts or performance-sensitive users. Highly customizable. See Customizing execution code generators.
Java Project for Rule Execution Server on Java SE For developers You use the Java project to generate an application from a decision service in Rule Designer for use as a RuleApp on Rule Execution Server.
JUnit Project for Rule Execution Server on Java SE For developers You use the JUnit project to generate an application from a decision service in Rule Designer for use as a RuleApp on Rule Execution Server.

Deciding how to choose a code generator

The following figure shows the decision pathway. Choose a code generator for your client project or write the execution code yourself.

Flow chart to choose the cod generator for client projects

Before you choose the appropriate factory and rule session, make the choice between Java SE and Java EE.

On Java EE, consider whether the call is local or remote, and whether you require transactions.
  • If you want to use Java SE, then create a Java Project for Rules and use the IlrJ2SESessionFactory class to write the execution code to call the rule session.
  • On Java EE, use the IlrPOJOSessionFactory class. This factory creates POJO rule sessions. In the Client Project for RuleApps wizard, use a POJO code generator to generate the client code.

Checking execution

You can use a number of features to check the results of your execution. Testing and simulation provides a way for you to test your results against an expected result in a controlled and measurable way. However, even without testing and simulation, Rule Execution Server provides some basic reporting to help you make some rapid conclusions about the success of your execution.

Execution trace

You can request a report of the execution from the calling client. This report is called a trace. Execution traces provide some details on the number of rules executed and the time that the ruleset took to execute. For more information, see Setting up ruleset execution traces.

Statistics
In the Rule Execution Server console, you can generate statistics for an executed ruleset. For more information, see Generating ruleset statistics.
Debug trace and configuration
By using the XU debug trace, you can see whether the XU configuration is working optimally. You can configure the trace to different levels depending on the amount of detail that is required. For more information, see Viewing debug traces for an execution unit (XU).

To debug your client projects, use the debug launch configuration for a remote Java application for rules.

Interceptors
You can also implement a ruleset interceptor and activate an execution trace from within the client. For more information, see Ruleset interceptors.