WebSphere ILOG JRules is IBM's best-of-breed Business Rule Management System (BRMS) that allows business users to dynamically control automated business decisions with business rules. JRules is used to define, deploy, execute, monitor and maintain decision logic that can be externalized from core enterprise systems allowing them to be more responsive to the rapidly changing needs of the business.
JRules provides functionality for authoring, executing and managing business rules. This article focuses on a specific technique for customizing the authoring environment involving integrating the JRules system with other back-end enterprise systems. Using the method introduced in this article, data can be pulled from any back-end system to be used in the JRules rule editor to populate drop-down boxes.
This article is written for the intermediate JRules developer and focuses on a specific area of implementation. It is assumed that the reader has a basic understanding of the ILOG JRules product from a developer's perspective. Please review the Resources section for relevant links to acquire the prerequisite knowledge for completing this article. Note the product versions used in this article:
- WebSphere ILOG Rule Studio V7.0.2
- WebSphere ILOG Rule Execution Server V7.0.2
- WebSphere ILOG Rule Team Server V7.0.2
This article and the sample are compatible with JRules V7.1.
The sample project provides a baseline for the work that we will do in this article. It is intended to provide a simple starting point for our exploration of the core topics that we are targeting in the article without spending time on the basics of rule development. Please refer to the prerequisites for more information.
To import the sample project, complete the following steps:
- Download SampleProjectPart1.zip from the Downloads section.
- Open Rule Studio and select File => Import => General =>
Existing Project into Workspace to import the sample project,
as shown in Figure 1.
Figure 1. Import dialog
- Select Next and import the DevWorksSample, as shown in Figure 2.
Figure 2. Import DevWorksSample
A domain is a model construct created inside of a Business Object Model
(BOM) that is used to place a restriction on the values that can be
assigned to attributes in a business rule. A dynamic domain allows an
enumeration of values to be set and updated dynamically by the execution
of Java™ code. In order to create a dynamic domain, you must first
create a Java class that implements the
IlrBOMDomainValueProvider interface, which
allows you to provide the collection of values with information on their
verbalization and BOM to XOM mapping. Next you must associate the domain
value provider with a BOM class and use the dynamic domain in a business
rule.
Create a domain value provider
To create a domain value provider, complete the following steps:
- Switch to the plug-in Development perspective, as shown in Figure 3.
- Create a new plug-in project, as shown in Figure 4.
- Set the Java compliance compiler level to 1.5, as shown in Figure 5.
Figure 3. Select plug-in project
Figure 4. Create plug-in project
Figure 5. Set the Java compliance compiler level to 1.5
- With the plug-in manifest editor open, add the following dependencies,
as shown in Figure 6:
- ilog.rules.vocabulary.bom(7.0.2)
- ilog.rules.studio.model(7.0.2)
Figure 6. Add required plug-ins
- Create a class and implement the interface
IlrBOMDomainValueProvider, as shown in Figure 7.
Figure 7. Create new class
- Provide a simple BOM2XOMMapping as shown in Listing 1:
Listing 1. BOM2XOMMappingpublic String getBOM2XOMMapping(Sting valueName) { return "return \"" + valueName + "\";"; }
- Provide the collection of domain values as shown in Listing 2:
Listing 2. Domain valuespublic Collection<String> getValues (IlrClass ilrClass) { HashSet<String> domainValues = new HashSet<String>(); domainValues.add("abcd") domainValues.add("efgh") domainValues.add("ijkl") return domainValues; }
Note: This code should be adapted to pull the domain values from an external data source. We are hardcoding them here so that we can focus on the creation of the domain value provider.
- With the plug-in manifest editor open, select the Extension
tab, then select Add to define the plug-in extension for the
class created above by selecting the
ilog.rules.studio.model.bomDomainValueProviders extension
point, as shown in Figure 10:
Figure 10. Add the extension point
- Complete the extension element details, as shown in Figure 11.
Figure 11. Complete the extension element details
- Add the package containing the domain value provider to the exported
packages list, as shown in Figure 12:
Figure 12. Add the package
- Deploy the plug-in by selecting File => Export => Plug-in
Development => Deployable plug-ins and fragments. Then
export the plug-in to the /InstallDir/studio/eclipse directory,
as shown in Figure 13.
Note:The plug-in must be re-deployed each time changes are made to the domain value provider code.
Figure 13. Deploy the plug-in
- Restart Eclipse.
Integrate the dynamic domain into Rule Studio
You have to associate the domain value provider with a BOM class.
- Switch to the Rule perspective and create a new class called
RoleCodes in the BOM, as shown in Figure 14.
Figure 14. RoleCodes class
- Set the execution class name to java.lang.String, as shown in Figure 15.
Figure 15. Execution class name
- Add a
domainValueProviderNamecustom property and set it to the domain provider (name property), as shown in Figure 16.
Figure 16. Custom domainValueProviderName property
- Ensure that the RoleCodes class has a default verbalization, as
shown in Figure 17.
Figure 17. Default verbalization
- In the domain section, select Create a domain, Static
References as the domain type, and select OK to create
the dynamic domain, as shown in Figure 18.
Note: If the OK button is not active, switch the domain type to Other, and then back to Static References, then select OK.
Figure 18. Create the domain
- After the previous step is completed, an empty enumerated domain is
created and the Synchronize link appears in the domain section.
Select this link to populate the enumerated domain, as shown in
Figures 19 and 20.
Note: If the value of the domainValueProviderName property is invalid, the following message appears in the domain section:The value provider is invalid. Check the custom properties.
Figure 19. Create the domain
Figure 20. Synchronized domain
Note: When the values of the domain change, the BOM can be updated using the Update the dynamic domains of this BOM entry link, as shown in Figure 21.
Figure 21. Update the dynamic domain
- Ensure that each member of the dynamic domain has a verbalization and
a label, as shown in Figure 22.
Figure 22. Verbalization and a label
- Change the data type of the roleCode member of the
RuleInput class, as shown in Figure 23.
Figure 23. Data type setting
Save all changes.
Use the Dynamic Domain in a Business Rule
- Locate the Approvers decision table and change the Role
Code condition column to use the new dynamic domain, as shown
in Figure 24.
Figure 24. Change the role code
Save all changes.
- Ensure that the dynamic domain is being used, as shown in Figure 25:
Figure 25. Domain being used
- Locate the UserRestrictions business rule and change the
Role Code entry to use the new dynamic domain, as shown in
Figure 26.
Figure 26. UserRestrictions business rule
Save all changes.
Integrate the Dynamic Domain into Rule Team Server
In order to make the dynamic domain available to Rule Team Server, the Java
class implementing the IlrBOMDomainValueProvider interface must be
packaged into the Rule Team Server EAR. This is typically done with an ant
command: ant repackage-ear ...
-DadditionalJars=../CustomDomainValueProvider.jar, where
CustomDomainValueProvider.jar contains the
IlrBOMDomainValueProvider implementation class.
The deployment process may vary depending on the application server being used. In this article, we are using WebSphere Application Server. Instead of reinstalling the Rule Team Server EAR, we will be deploying our domain value provider by placing our JAR file directly into the EAR directory on the file system.
- Create a properties file named
preferences.propertiesand place it into the src folder of the plug-in project, as shown in Figures 27 and 28. The property to be placed inside of the file will take the following format: teamserver.myProviderName=fully qualified implementation class name, where myProviderName represents the domain provider (name property) used in Figure 10 above.
Figure 27. Create a properties file
Figure 28. preferences.properties
- Select File - > Export - > Java - > JAR file to export
the domain value provider, as shown in Figure 29.
Figure 29. Export domain value provider
- Use a method recommended by your application server to package the JAR
file into the Rule Team Server EAR and re-deploy. as stated above,
this will typically involve the use of the ant command. In this
article, we will be placing the JAR file into the
/
profileDirectory/installedApps/cellDirectory/teamserver-WAS61.ear/teamserver.war/WEB-INF/lib directory on the server. - Deploy the rule project to the Rule Team Server, as shown in Figure 30.
Figure 30. Deploy the rule project
- Logon to the Rule Team Server and verify that the dynamic domain is
being used by the rules, as shown in Figures 31 and 32.
Figure 31. Approvers Table
Figure 32. UserRestrictions Business Rule
- When the values of the dynamic domain changes, the domain needs to be
refreshed. In the Rule Team Server under the Project tab,
select
Reload Dynamic Domains, as shown in Figures 33 and 34.
Figure 33. Reload Dynamic Domains
Figure 34. Dynamic Domains Refreshed
| Description | Name | Size | Download method |
|---|---|---|---|
| Sample project for this tutorial | SampleProjectPart1.zip | 12KB | HTTP |
| Solution project for this tutorial | SolutionProjectPart1.zip | 18KB | HTTP |
Information about download methods
Learn
-
WebSphere ILOG JRules Information
Center
The information center contains information describing the IBM WebSphere ILOG JRules BRMS product line and features. -
WebSphere ILOG JRules Home
Page
IBM WebSphere ILOG JRules provides functionality to build and deploy rule-based applications for Java, mainframe and SOA-based environments.
Get products and technologies
-
WebSphere ILOG JRules V7.1
Get the trial download. -
WebSphere ILOG Business Rules Management Systems zone
Get the latest technical resources on IBM ILOG solutions, including downloads, demos, articles, tutorials, events, webcasts, and more.
Discuss
- Get involved in the My developerWorks community:
Connect with other developerWorks users while exploring the
developer-driven blogs, forums, groups, and wikis.

Tamer Nassar is a software engineer in the office of the IBM CIO, and has been with IBM since 2000. He has been involved in different projects, with a variety of technologies, designing, implementing, and testing many end-to-end enterprise solutions. His areas of interest and expertise include SOA, IT architecture and methodology, WebSphere Application Server, WebSphere Process Server, WebSphere MQ, and WebSphere Message Broker.




