Java EE rule session sample details

You use a web browser to run this sample.

Running this sample

To run this sample:

  1. Open a web browser and type the appropriate URL for your application server:
    WebSphere® 8.5
    http://localhost:<PORT>/rulesession
    WebSphere 8.0
    http://localhost:<PORT>/rulesession
    WebLogic Server 10 and 12
    http://localhost:7001/rulesession
    Tomcat 7
    http://localhost:8080/rulesession
  2. Log in by using the following user name and password:
    • User name: resAdmin
    • Password: resAdmin
  3. Click the Explorer tab. The application server displays the available rulesets.
  4. Click View to view the Business Action Language (BAL) rules that are contained in the ruleset.
  5. Click Deploy to deploy the ruleset (for example, balsample2).
  6. Select the Execution tab.

    The Java™ rule session produces an execution report. In the Rule execution section, each icon represents a different mode of executing a ruleset.

  7. Click the Java Rule Session icon.
    The execution results and the execution report display the following information:
    • Execution results
      • Messages: Parameters with values that are affected by the execution of the rules.
      • Normal Price: The normal price of the item.
      • Discount: The discount that the rules calculate.
      • Final Price: The cost of the item minus the calculated discount.
    • Execution report
      The IlrExecutionTrace API provides access to information about the execution such as working memory, execution time, and number of executed rules. The sample displays the following trace information:
      • The number of executed rules.
      • The executed rules.
  8. On the application servers that support Enterprise JavaBeans (EJB), you can also execute the rules remotely by using a Java client, as follows:
    1. Switch to the Samples Console perspective.
    2. In the Samples Commands view, navigate to Samples Commands > Rule Execution Server > Java EE rule session > <appserver_name>.
      The <appserver_name> variable is one of the following application servers:
      • WebSphere Application Server 8.5 (sample server): websphere85
      • WebSphere Application Server 8.0: websphere8
      • WebLogic Server 10: weblogic10
      • WebLogic Server 12: weblogic12
    3. Make sure that you have deployed the ruleset, as described in step 5.
    4. Expand Commands and double-click the run command. If your are working on the sample server, you are prompted for your credentials. Enter resAdmin and resAdmin for both the user name and the password.

How this sample works

This sample demonstrates the use case of a Java EE execution stack in EJB, plain Java objects (POJO), and JSR-94 modes.

In the sample, you can perform the following tasks:
  • Deploy a RuleApp using a web interface.
  • Execute rules from a web interface.
  • Execute rules remotely from a Java client.

You can deploy and execute the sample on all supported platforms.

Shows how this sample can be deployed and executed on all supported platforms

Source files

The source files for this sample are in the following directories:
  • Sample: <InstallDir>/executionserver/samples/j2eerulesession
  • XOM source files: <InstallDir>/executionserver/samples/j2eerulesession/src/shopmodel
  • Web-tier control classes: <InstallDir>/executionserver/samples/j2eerulesession/src/controller
  • Java remote clients: <InstallDir>/executionserver/samples/j2eerulesession/src/client
  • JavaServer Pages (JSP): <InstallDir>/executionserver/samples/j2eerulesession/src/WebContent
You can also view and modify the sample source files in Rule Designer. To import the sample into your workspace:
  1. Click Import projects in the Samples and Tutorials view under Rule Execution Server / Samples/ Java EE rule session.
  2. Switch to the Java perspective.