Java EE rule session sample details
You use a web browser to run this sample.
Running this sample
To run this sample:
- Open a web browser and type the appropriate URL for your application
server:
- WebSphere® Application Server 8.5 or 8.5.5
- http://localhost:<PORT>/rulesession
- WebLogic Server and 12
- http://localhost:7001/rulesession
- Tomcat 7
- http://localhost:8080/rulesession
- Log in by using the following user name and password:
- User name: resAdmin
- Password: resAdmin
- Click the Explorer tab. The application server displays the available rulesets.
- Click View to view the Business Action Language (BAL) rules that are contained in the ruleset.
- Click Deploy to deploy the ruleset (for example, balsample2).
- 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.
- 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 reportThe 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.
- Execution results
- On the application servers that support Enterprise JavaBeans (EJB), you can also execute the
rules remotely by using a Java client,
as follows:
- Switch to the Samples Console perspective.
- In the Samples Commands view, navigate to .The <appserver_name> variable is one of the following application servers:
- WebSphere Application Server 8.5 or 8.5.5 (sample server): websphere85
- WebLogic Server 12: weblogic12
- Make sure that you have deployed the ruleset, as described in step 5.
- 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 and plain Java objects (POJO).
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.

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:
- Click Import projects in the Samples and Tutorials view under Rule Execution Server / Samples/ Java EE rule session.
- Switch to the Java perspective.