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 enter the URL for your application server:
    WebSphere Liberty 16 (sample server)
    http://localhost:9090/rulesession
    WebSphere® Application Server 8.5 or 8.5.5
    http://localhost:<PORT>/rulesession
    WebLogic Server 12
    http://localhost:7001/rulesession
    Tomcat
    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 Deploy to deploy the ruleset (for example, balsample2).
  5. Select the Execution tab.

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

  6. Click the execution button that you want to test, for example, on Liberty, click Execute Ruleset in J2SE Mode.
    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 run rules. The sample displays the following trace information:
      • The number of run rules.
      • The run rules.
  7. On the application servers that support Enterprise JavaBeans (EJB), you can also run 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 or 8.5.5: websphere85
      • WebLogic Server 12: weblogic12
    3. Check the deployment of 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 for both the user name and the password.

How this sample works

This sample demonstrates a Java EE execution stack in EJB and plain Java objects (POJO).

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

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

The image shows how this sample can be deployed and run 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.