|
Rule Execution Server API | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
---|---|
IlrRuleServiceProvider | Deprecated. JSR94 support is deprecated and will be removed in a future ODM release. |
Provides the classes that implement the JavaTM Rule Engine API (JSR-94) on top of Rule Execution Server.
JSR-94 is not implemented in the engine API, it delegates the JRules rule
sessions using the jrules-res-jsr94.jar
archive. The JSR-94
specification includes a javax.rules
package. This package
contains classes and interfaces aimed at the runtime clients of the rule engine.
The following code example illustrates how to use JSR-94:
public class JSR94CodeSample { /** * The path of the ruleset used to compute fibonacci numbers. * * The ruleset takes an input parameter 'n' of type java.lang.Integer. * The result is inserted into the working memory. */ public static final String rulesetPath = "/jsr94/1.0/fibo/1.0"; public JSR94CodeSample() throws ClassNotFoundException { //Loads the rule service. Class.forName(IlrRuleServiceProvider.class.getName()); } /** * Returns the rule runtime. */ RuleRuntime getRuleRuntime() throws RuleException { // Returns the rule runtime object. RuleServiceProvider provider = RuleServiceProviderManager.getRuleServiceProvider(IlrRuleServiceProvider.URI); RuleRuntime runtime = provider.getRuleRuntime(); return runtime; } /** * Computes fibonacci numbers. */ public int computeFibonacciWithStatelessRuleSession(int n) throws RemoteException, RuleException { // Prepares the parameters Mapparameters = new HashMap (); parameters.put("n", new Integer(n)); // Creates the rule session StatelessRuleSession session = (StatelessRuleSession)getRuleRuntime().createRuleSession("/jsr94/1.0/fibo/1.0", parameters, RuleRuntime.STATELESS_SESSION_TYPE); // Executes the rules List workingMemory = session.executeRules(null); // Returns the result which is in the working memory return (Integer)workingMemory.get(0); } /** * Computes fibonacci numbers. */ public int computeFibonacciWithStatefulRuleSession(int n) throws RemoteException, RuleException { // Prepares the parameters Map parameters = new HashMap (); parameters.put("n", new Integer(n)); // Creates the rule session StatefulRuleSession session = (StatefulRuleSession)getRuleRuntime().createRuleSession("/jsr94/1.0/fibo/1.0", parameters, RuleRuntime.STATEFUL_SESSION_TYPE); // Executes the rules session.executeRules(); List workingMemory = session.getObjects(); // Returns the result which is in the working memory return (Integer)workingMemory.get(0); } }
|
Rule Execution Server API | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |