|
ILOG JRules | |||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||
See:
Description
| Interface Summary | |
|---|---|
| IlrJSR94Constants | Provides a set of constant properties (keys and values) that specify the environment and persistence type of Rule Execution Server. |
| Class Summary | |
|---|---|
| IlrRuleServiceProvider | Finds a javax.rules.RuleServiceProvider for the JRules JSR-94 implementation. |
Provides the classes that implements the JavaTM Rule Engine API (JSR-94) on top of Rule Execution Server. JSR-94 delegates the JRules rule sessions using a Java archive file, named jrules-bres-jsr94.jar. It is not implemented in the engine API. The JSR-94 specification includes a javax.rules package, which contains classes and interfaces that are aimed at runtime clients of the rule engine.
The following code shows an example of what you will need to do to execute rules using both Rule Execution Server and the JSR-94 implementation:
Map parameters = new HashMap();
// Parameters for the ruleset
parameters.put("customer", user);
parameters.put("shoppingCart", cart);
parameters.put("isJSR94", new Boolean(true));
// Property for ILOG JSR-94 to set the environment to J2EE.
parameters.put("ilog.rules.bres.jsr94.environment_type", new Byte((byte) 1));
// Property for ILOG JSR-94 to set the userData.
parameters.put("ilog.rules.bres.jsr94.user_data", "j2eesample.jsr94");
// Initialization in J2EE (not the same in J2SE).
RuleServiceProvider ruleServiceProvider = new IlrRuleServiceProvider();
RuleRuntime ruleRuntime = null;
// Retrieves RuleRuntime object.
try {
ruleRuntime = ruleServiceProvider.getRuleRuntime();
}
// Sets the ruleset path.
String rulesetPath = new String("/" + RuleAppController.RULEAPPNAME
+ "/" + RuleAppController.RULESETNAME);
StatelessRuleSession ruleSession = null;
// Creates a rule session.
try {
ruleSession = (StatelessRuleSession) ruleRuntime.createRuleSession(rulesetPath,
parameters, RuleRuntime.STATELESS_SESSION_TYPE);
}
List workingMemoryAfterExecution = null;
// Executes the rules.
try {
workingMemoryAfterExecution = ruleSession.executeRules(null);
if (workingMemoryAfterExecution.size()>0)
sresult = (StringBuffer)workingMemoryAfterExecution.get(0);
}
The JSR-94 implementation is applicable to both J2SE and J2EE platforms. For more information on JSR-94 refer to the specification: http://jcp.org/aboutJava/communityprocess/final/jsr094/index.html.
|
ILOG JRules | |||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||