Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Business Rules
11g Release 1 (11.1.1.6.2)

E10663-08


oracle.rules.rl
Class RuleSession

java.lang.Object
  extended by oracle.rules.rl.RuleSession

All Implemented Interfaces:
java.io.Serializable

public class RuleSession
extends java.lang.Object
implements java.io.Serializable

RuleSession is the public API for executing Oracle Rule Language.

See Also:
Serialized Form

Nested Class Summary
 class RuleSession.ParsedRulesetInfo
          ParsedRulesetInfo -- a bean for holding the result of a parse

 

Field Summary
static java.lang.String CFG_APP_NAME
          The key for setting the application (or component) name to associate this RuleSession with for DMS statistics.
static java.lang.String CFG_DECISION_TRACE_LEVEL
          The key for specifying the decision trace level at RuleSession instantiation.
static java.lang.String CFG_DECISION_TRACE_LIMIT
          The key for specifying the decision trace limit at RuleSession instantiation.
static java.lang.String CFG_DMS
          The key for setting the Boolean to enable DMS for this RuleSession.
static java.lang.String CFG_LOCALE
          The key for setting the Locale for this RuleSession.
static java.lang.String CFG_LOGGING
          The key for setting the Boolean to enable logging for this RuleSession.
static java.lang.String CFG_SESSION_NAME
          The key for setting the string to use for this RuleSession.
static java.lang.String CFG_WATCH
          The key for specifying the watch options at RuleSession instantiation.
static int DECISION_TRACE_DEVELOPMENT
          The decision trace level to use for debugging or more detailed tracing.
static int DECISION_TRACE_OFF
          The decision trace level that disables decision tracing.
static int DECISION_TRACE_PRODUCTION
          The decision trace level for use in production.
static java.lang.String RL_LOGGER
           
static int WATCH_ACTIVATIONS
          Watch the addition or removal of activations from the agenda.
static int WATCH_ALL
          Watch all rule engine activity.
static int WATCH_COMPILATIONS
          Watch rule compilation into the Rete network.
static int WATCH_FACTS
          Watch the assertion, retraction, or modification of facts in working memory.
static int WATCH_FOCUS
          Watch ruleset stack changes.
static int WATCH_RULES
          Watch rules fire.

 

Constructor Summary
RuleSession()
          Construct a new RuleSession, containing a Rete Engine and Working Memory.
RuleSession(java.util.List<java.lang.String> rlList, java.util.Map config)
          Construct a new RuleSession, containing a Rete Engine and Working Memory.
RuleSession(java.util.Map config)
          Construct a new RuleSession, containing a Rete Engine and Working Memory.

 

Method Summary
 java.lang.Object assertTree(java.lang.Object root)
          Asserts as facts objects from an object tree.
 java.lang.Object assertTree(java.lang.String spec, java.lang.Object root)
          Asserts as facts objects from an object tree.
 void assertXPath(java.lang.String pkg, java.lang.Object element, java.lang.String xpath)
          Deprecated. 
 java.lang.Object callFunction(java.lang.String functionName)
          Execute the RL function with no arguments, returning result.
 java.lang.Object callFunctionWithArgument(java.lang.String functionName, java.lang.Object arg)
          Execute the RL function with one argument, returning result.
 java.lang.Object callFunctionWithArgumentArray(java.lang.String functionName, java.lang.Object[] args)
          Execute the RL function with given array arguments, returning result.
 java.lang.Object callFunctionWithArgumentList(java.lang.String functionName, java.util.List args)
          Execute the RL function with given list of arguments, returning result.
 java.lang.Object callFunctionWithArguments(java.lang.String functionName, java.lang.Object... args)
          Execute the RL function with given arguments, returning result.
 void executeRuleset(java.io.Reader rulesetReader)
          Execute the ruleset
 void executeRuleset(java.lang.String rulesetString)
          Execute the ruleset
 java.util.Iterator getFactIds()
          Get an Iterator over the fact IDs for the objects that have been asserted as facts in working memory.
 java.util.Iterator getFactObjects()
          Get an Iterator over the objects that have been asserted as facts in working memory.
 java.util.Iterator getFactObjects(ObjectFilter filter)
          Get an Iterator over the objects in working memory that pass the specified filter.
 java.util.Locale getLocale()
          Get the Locale for the rule session.
 java.lang.String getName()
          Get the name associated with this rule session.
 java.io.Writer getOutputWriter()
          Get the writer used by RL println, show, and watch functions.
 Ruleset getRuleset(java.lang.String name)
          Returns the Ruleset for the ruleset with the specified name.
 java.lang.String getRulesetName()
          Get the name of the implicit ruleset for top level definitions (default is "main").
 java.util.Map<java.lang.String,Ruleset> getRulesets()
          Returns a Map containig a String,Ruleset key,value pair for each ruleset defined in this RuleSession.
 java.lang.Object getVariable(java.lang.String name)
          Returns the value of the specified RL global variable.
 boolean isFrozen()
          Returns true if this RuleSession has been completely defined from a List of RL text.
 boolean isSupportsXPathEnabled()
          Returns true if "supports xpath" is enabled (the default).
 boolean isValid()
          Returns true if this RuleSession is valid.
 RuleSession.ParsedRulesetInfo parseRuleset(java.io.Reader rulesetReader)
           
 RuleSession.ParsedRulesetInfo parseRuleset(java.lang.String rulesetString)
          Parse and return info about the given ruleset.
 void setOutputWriter(java.io.Writer w)
          Set the writer used by RL println, show, and watch functions.
 void setRulesetName(java.lang.String n)
          Set the name of the implicit ruleset for top level definitions (default is "main").
 boolean setSupportsXPathEnabled(boolean newValue)
          Enables (disables) "supports xpath" by specifying a new value of true (false).
 void setVariable(java.lang.String name, java.lang.Object value)
          Sets the value of the specified RL global variable.

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

CFG_LOCALE

public static final java.lang.String CFG_LOCALE
The key for setting the Locale for this RuleSession. a RuleSession.
See Also:
Constant Field Values

CFG_SESSION_NAME

public static final java.lang.String CFG_SESSION_NAME
The key for setting the string to use for this RuleSession.
See Also:
Constant Field Values

CFG_LOGGING

public static final java.lang.String CFG_LOGGING
The key for setting the Boolean to enable logging for this RuleSession.
See Also:
Constant Field Values

CFG_DMS

public static final java.lang.String CFG_DMS
The key for setting the Boolean to enable DMS for this RuleSession.
See Also:
Constant Field Values

CFG_APP_NAME

public static final java.lang.String CFG_APP_NAME
The key for setting the application (or component) name to associate this RuleSession with for DMS statistics.
See Also:
Constant Field Values

CFG_WATCH

public static final java.lang.String CFG_WATCH
The key for specifying the watch options at RuleSession instantiation. The available watch options are defined as WATCH_xx constants. Multiple options may be configured by or'ng them together. For example:
Integer watchConfig = Integer.valueOf(RuleSession.WATCH_RULES | RuleSession.WATCH_FACTS); configMap.put(RuleSession.CFG_WATCH, watchConfig);
These options are restored by the built-in reset function.
See Also:
RuleSession.WATCH_RULES, RuleSession.WATCH_ACTIVATIONS, RuleSession.WATCH_FACTS, RuleSession.WATCH_FOCUS, RuleSession.WATCH_COMPILATIONS, RuleSession.WATCH_ALL, Constant Field Values

WATCH_RULES

public static final int WATCH_RULES
Watch rules fire.
See Also:
RuleSession.CFG_WATCH, Constant Field Values

WATCH_ACTIVATIONS

public static final int WATCH_ACTIVATIONS
Watch the addition or removal of activations from the agenda.
See Also:
RuleSession.CFG_WATCH, Constant Field Values

WATCH_FACTS

public static final int WATCH_FACTS
Watch the assertion, retraction, or modification of facts in working memory.
See Also:
RuleSession.CFG_WATCH, Constant Field Values

WATCH_FOCUS

public static final int WATCH_FOCUS
Watch ruleset stack changes.
See Also:
RuleSession.CFG_WATCH, Constant Field Values

WATCH_COMPILATIONS

public static final int WATCH_COMPILATIONS
Watch rule compilation into the Rete network.
See Also:
RuleSession.CFG_WATCH, Constant Field Values

WATCH_ALL

public static final int WATCH_ALL
Watch all rule engine activity.
See Also:
RuleSession.CFG_WATCH, Constant Field Values

CFG_DECISION_TRACE_LEVEL

public static final java.lang.String CFG_DECISION_TRACE_LEVEL
The key for specifying the decision trace level at RuleSession instantiation.
See Also:
RuleSession.DECISION_TRACE_OFF, RuleSession.DECISION_TRACE_PRODUCTION, RuleSession.DECISION_TRACE_DEVELOPMENT, Constant Field Values

DECISION_TRACE_OFF

public static final int DECISION_TRACE_OFF
The decision trace level that disables decision tracing.
See Also:
Constant Field Values

DECISION_TRACE_PRODUCTION

public static final int DECISION_TRACE_PRODUCTION
The decision trace level for use in production. Rules fired and fact operations are traced. Fact properties are not included in the trace.
See Also:
Constant Field Values

DECISION_TRACE_DEVELOPMENT

public static final int DECISION_TRACE_DEVELOPMENT
The decision trace level to use for debugging or more detailed tracing. Full decision tracing equivalent to invoking WATCH_ALL plus tracing invocations of the reset function.
See Also:
Constant Field Values

CFG_DECISION_TRACE_LIMIT

public static final java.lang.String CFG_DECISION_TRACE_LIMIT
The key for specifying the decision trace limit at RuleSession instantiation.
See Also:
Constant Field Values

RL_LOGGER

public static final java.lang.String RL_LOGGER
See Also:
Constant Field Values

Constructor Detail

RuleSession

public RuleSession(java.util.Map config)
            throws RLException
Construct a new RuleSession, containing a Rete Engine and Working Memory.
Parameters:
config - session configuration parameters
Throws:
RLException

RuleSession

public RuleSession()
            throws RLException
Construct a new RuleSession, containing a Rete Engine and Working Memory. Use default locale.
Throws:
RLException

RuleSession

public RuleSession(java.util.List<java.lang.String> rlList,
                   java.util.Map config)
            throws RLException
Construct a new RuleSession, containing a Rete Engine and Working Memory. If the list of RL, rlList, is not null, the RuleSession is initialized with the RL in the list and then frozen. A RuleSession that has been frozen does not allow executeRuleset to be invoked.
Parameters:
rlList - an optional list of RL text
config - session configuration parameters
Throws:
RLException

Method Detail

getOutputWriter

public java.io.Writer getOutputWriter()
Get the writer used by RL println, show, and watch functions.
Returns:
Writer

setOutputWriter

public void setOutputWriter(java.io.Writer w)
Set the writer used by RL println, show, and watch functions. Default is System.out. Default is used for new and deserialized RuleSessions.
Parameters:
w - Writer to set

getName

public java.lang.String getName()
Get the name associated with this rule session.
Returns:
rule session name

getRulesetName

public java.lang.String getRulesetName()
Get the name of the implicit ruleset for top level definitions (default is "main").
Returns:
ruleset name

setRulesetName

public void setRulesetName(java.lang.String n)
Set the name of the implicit ruleset for top level definitions (default is "main").
Parameters:
n - the implicit ruleset name

getLocale

public java.util.Locale getLocale()
Get the Locale for the rule session.
Returns:
Locale

executeRuleset

public void executeRuleset(java.lang.String rulesetString)
                    throws RLException
Execute the ruleset
Parameters:
rulesetString - String containing ruleset text
Throws:
RLException

executeRuleset

public void executeRuleset(java.io.Reader rulesetReader)
                    throws RLException
Execute the ruleset
Parameters:
rulesetReader - Reader containing ruleset text
Throws:
RLException

callFunction

public java.lang.Object callFunction(java.lang.String functionName)
                              throws RLException
Execute the RL function with no arguments, returning result.
Parameters:
functionName - name of RL function, optionally ruleset-qualified
Returns:
Object result of RL function
Throws:
RLException

callFunctionWithArgument

public java.lang.Object callFunctionWithArgument(java.lang.String functionName,
                                                 java.lang.Object arg)
                                          throws RLException
Execute the RL function with one argument, returning result.
Parameters:
functionName - name of RL function, optionally ruleset-qualified
arg - Object to pass to function
Returns:
Object result of RL function
Throws:
RLException

callFunctionWithArgumentArray

public java.lang.Object callFunctionWithArgumentArray(java.lang.String functionName,
                                                      java.lang.Object[] args)
                                               throws RLException
Execute the RL function with given array arguments, returning result.
Parameters:
functionName - name of RL function, optionally ruleset-qualified
args - array of arguments to pass to function
Returns:
Object result of RL function
Throws:
RLException

callFunctionWithArguments

public java.lang.Object callFunctionWithArguments(java.lang.String functionName,
                                                  java.lang.Object... args)
                                           throws RLException
Execute the RL function with given arguments, returning result.
Parameters:
functionName - name of RL function, optionally ruleset-qualified
args - vararg arguments to pass to function
Returns:
Object result of RL function
Throws:
RLException

callFunctionWithArgumentList

public java.lang.Object callFunctionWithArgumentList(java.lang.String functionName,
                                                     java.util.List args)
                                              throws RLException
Execute the RL function with given list of arguments, returning result.
Parameters:
functionName - name of RL function, optionally ruleset-qualified
args - list to pass to function
Returns:
Object result of RL function
Throws:
RLException

assertTree

public java.lang.Object assertTree(java.lang.Object root)
                            throws RLException
Asserts as facts objects from an object tree. Objects in the tree are asserted according to relationships that have been defined for the object's class or a class in its inheritancy graph. This form is intended only for use with RL generated from the oracle.rules.sdk2 rules SDK.
Parameters:
root - the root of the object tree.
Returns:
the root of the tree.
Throws:
RLException - if an error occurs asserting the object tree

assertTree

public java.lang.Object assertTree(java.lang.String spec,
                                   java.lang.Object root)
                            throws RLException
Asserts as facts objects from an object tree. The spec argument is a colon separated list of package names and controls which objects are asserted. If an object in the tree is in one of the packages in the list, it will be asserted and assertTree will recurse over its bean properties.
Parameters:
spec - a list of colon separated packages.
root - the root of the object tree.
Returns:
the root of the tree.
Throws:
RLException - if an error occurs asserting the object tree

assertXPath

@Deprecated
public void assertXPath(java.lang.String pkg,
                                   java.lang.Object element,
                                   java.lang.String xpath)
                 throws RLException
Deprecated. 
Throws:
RLException

parseRuleset

public RuleSession.ParsedRulesetInfo parseRuleset(java.lang.String rulesetString)
                                           throws RLException
Parse and return info about the given ruleset. Info includes JAXB parse tree, names and definitions for all classes, functions, and variables organized by ruleset, and java classes appearing in fact context in this ruleset, organized by package.
Returns:
ParsedRulesetInfo
Throws:
RLException

parseRuleset

public RuleSession.ParsedRulesetInfo parseRuleset(java.io.Reader rulesetReader)
                                           throws RLException
Throws:
RLException

getFactObjects

public java.util.Iterator getFactObjects()
Get an Iterator over the objects that have been asserted as facts in working memory.
Returns:
the iterator over objects in working memory.

getFactObjects

public java.util.Iterator getFactObjects(ObjectFilter filter)
Get an Iterator over the objects in working memory that pass the specified filter.
Returns:
the iterator over objects in working memory that pass the specified filter.

getFactIds

public java.util.Iterator getFactIds()
Get an Iterator over the fact IDs for the objects that have been asserted as facts in working memory. Each fact ID (an int, is wrapped in an Integer.
Returns:
Iterator

getRuleset

public Ruleset getRuleset(java.lang.String name)
Returns the Ruleset for the ruleset with the specified name.
Parameters:
name - the ruleset name.
Returns:
the Ruleset for the ruleset with the specified name.

getRulesets

public java.util.Map<java.lang.String,Ruleset> getRulesets()
Returns a Map containig a String,Ruleset key,value pair for each ruleset defined in this RuleSession.
Returns:
the Map of Ruleset's.

setSupportsXPathEnabled

public boolean setSupportsXPathEnabled(boolean newValue)
Enables (disables) "supports xpath" by specifying a new value of true (false). Disabling "supports xpath" may improve performance when assertXPath and/or XML facts are used. In order to realize the performance improvements, this should be invoked with a value of false before any RL is executed. If "supports xpath" is disabled:
Parameters:
newValue - the new value
Returns:
the previous value

isSupportsXPathEnabled

public boolean isSupportsXPathEnabled()
Returns true if "supports xpath" is enabled (the default).

getVariable

public java.lang.Object getVariable(java.lang.String name)
                             throws RLException
Returns the value of the specified RL global variable. The name must be fully qualified.
Returns:
the value of the specified RL global variable.
Throws:
RLException - if no such global variable exists.

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value)
                 throws RLException
Sets the value of the specified RL global variable. The name must be fully qualified.
Throws:
RLException - if no such global variable exists or if the specified value can not be assigned to the variable.

isValid

public boolean isValid()
Returns true if this RuleSession is valid. Returns false if the RuleSession has encountered an error and should no longer be used.

isFrozen

public boolean isFrozen()
Returns true if this RuleSession has been completely defined from a List of RL text. If a RuleSession is frozen, attempts to invoke executeRuleset will throw an exception.

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Business Rules
11g Release 1 (11.1.1.6.2)

E10663-08


Copyright © 2012, Oracle and/or its affiliates. All rights reserved.