public interface RuleSession
RuleSession
has to be created by the rule engine host to
evaluate rules for a set of conditions. RuleSession can be created by
invoking any of the following APIs.
RuleEngine.createRuleSession(String, String, TriggerEvents, String)
RuleEngine.createRuleSession(String, String)
RuleEngine.createRuleSession(com.cordys.bre.repository.IRule[], String)
RuleSession
is created, to execute rules or decision case,
client is expected to call executeRules()
or
executeDecisionCase(String)
method respectively. Finally,
cleanUp()
has to be called to clean up all the NOM node pointers
created for the objects in the rule session.
Note: User should be a valid LDAP user
For example, user =
"cn=john,cn=organizational
users,o=system,cn=cordys,cn=defaultInst,o=vanenburg.com"
RuleSession ruleSession = ruleEngine.createRuleSession(uriBinding, ruleType, triggerEvent, user); XObject xObject = new XObjectImpl(Node.getFirstChild(iObjects)); ruleSession.setTriggerObject(xObject); ruleSession.setTransactionContext(null); // transaction object if any try { ruleSession.executeRules();//Marks the actual start of a rule execution cycle } finally { ruleSession.cleanUp(); }
Modifier and Type | Method and Description |
---|---|
boolean |
actionExecuted()
Returns whether any action was taken as part of the rule execution
|
int |
addObject(XObject object)
Add the xobject to the rule session context.
|
void |
cleanUp()
To clean up the rulesession after (executeRules method)executing the
rules.If a cleanUp is called by the client after calling execute rules
there is a possibility of memory leak as NOM nodes
|
void |
disableRuleMonitoring()
Use this API to disable rule monitoring.
|
void |
enableRuleMonitoring()
Use this API to turn ON Rule Monitoring.
|
int |
executeDecisionCase(java.lang.String dcId)
Executes the decision case whose Id is passed.
|
void |
executeRules()
Executes the rules as applicable to this rule session.
|
XObject |
getObject(java.lang.String xobjectIdentifer)
Gets the xobject from rule session context.
|
int |
getObjectContext()
Gets the int objects node from rule session used for rule evaluation.
|
java.lang.String |
getOrgContext()
Returns the organizational context associated with this
RuleSession |
RuleEngine |
getRuleEngine()
Returns the
RuleEngine in which the rule session executes. |
IRuleSet |
getRuleSet()
Gets the ruleset from rule session used for rule evaluation.
|
java.lang.String |
getRuleType()
Returns the type of rules for the current rule execution cycle
|
java.lang.String |
getSessionId()
returns the rule session id
|
java.lang.Object |
getTransactionContext()
Returns the transaction context associated with this rule session
|
java.lang.String |
getTransactionId()
Returns the transaction id associated with this rule session
|
TriggerEvents |
getTriggerEvent() |
XObject |
getTriggerObject()
Returns the trigger object for the rule.
|
java.lang.String |
getUriBinding()
Returns the URI Binding for the current rule execution cycle
|
java.lang.String |
getUser()
Returns the user associated with this
RuleSession |
int |
getXmlObjectFromContext(java.lang.String tagname,
java.lang.String namespace)
Gets the int object node from rule session context by xml tagname and
namesapce.
|
boolean |
hasSatifiedRuleCondition()
Returns whether any if/condition of rules in the ruleset has satisfied
condition as part of rule execution
|
boolean |
isRuleMonitoringEnabled()
This method overrides the rule monitoring value set at a global level
i.e.
|
boolean |
isTriggerObject(java.lang.String xobjectIdentifer) |
void |
refreshXObjects()
Refreshs the xobjects in the context of the rule session
|
void |
removeObject(java.lang.String xobjectIdentifer)
Removes the xobject from rule session context.
|
void |
removeObject(XObject object)
Removes the xobject from rule session context.
|
void |
setActionExecuted(java.lang.String actionname)
Sets action executed flag to true for actionname, this is internally set
by rule-engine when any action is taken while evaluation
|
void |
setTransactionContext(java.lang.Object transaction)
Sets the transaction context on the rule session .This could be any
object implementation for the host transaction .
|
void |
setTransactionId(java.lang.String transactionId)
Sets the transaction id on the rule session.
|
void |
setTriggerObject(XObject object)
Sets the object triggering the rule.
|
void |
setUser(java.lang.String user)
Deprecated.
|
java.lang.String getSessionId()
RuleEngine getRuleEngine()
RuleEngine
in which the rule session executes.RuleEngine
java.lang.String getRuleType()
java.lang.String getUriBinding()
void setTriggerObject(XObject object)
The
- object XObject
passed to the rule engine for
applying the rules.XObject getTriggerObject()
XObject
for the current rule
sessionboolean isTriggerObject(java.lang.String xobjectIdentifer)
int addObject(XObject object)
The
- object XObject
to be added to the contextvoid removeObject(XObject object)
The
- object XObject
to be removed from the contextvoid removeObject(java.lang.String xobjectIdentifer)
The
- String identifier for the XObject
to be removed
from the contextXObject getObject(java.lang.String xobjectIdentifer)
The
- String identifier for the XObject
to be fetched
from the contextvoid refreshXObjects()
int getXmlObjectFromContext(java.lang.String tagname, java.lang.String namespace)
string
- tagnamenamespace
- of the xml node that is to be retrievedIRuleSet getRuleSet()
IRuleSet
which is used for rule evaluationint getObjectContext()
Node
pointer to the objects used in rule sessionvoid setTransactionContext(java.lang.Object transaction)
Object
- - the transaction objectvoid setTransactionId(java.lang.String transactionId)
transactionId
- java.lang.String getTransactionId()
java.lang.Object getTransactionContext()
java.lang.String getUser()
RuleSession
user
associated with this
RuleSession
@Deprecated void setUser(java.lang.String user)
user
- the user context for the current rule execution cycle.User
should be a valid LDAP uservoid executeRules() throws RuleExecutionException
RuleExecutionException
int executeDecisionCase(java.lang.String dcId) throws RuleExecutionException
dcId
- RuleExecutionException
boolean actionExecuted()
boolean hasSatifiedRuleCondition()
void setActionExecuted(java.lang.String actionname)
void cleanUp()
java.lang.String getOrgContext()
RuleSession
orgContext
associated with this
RuleSession
boolean isRuleMonitoringEnabled()
#enableRuleMonitoring(boolean)
API. If #enableRuleMonitoring(boolean)
is never called then
global configuration is consideredvoid enableRuleMonitoring()
Rule monitoring setting is available
A sample use case is when a BPM executes a series of decision table activities it might want to monitor only a specific decision table activity; rest of the decision table activities need not be monitored. This is where BPM framework will influence the default rule monitoring property using this API
void disableRuleMonitoring()
TriggerEvents getTriggerEvent()