public interface RuleEngine
<configurations> <user>cn=SYSTEM,cn=organizational users,o=system,cn=cordys,o=vanenburg.com</user> <organization>o=system,cn=cordys,o=vanenburg.com</organization> <configuration htmfile="/cordys/ruleengine/admin/ruleengineConfig.htm" implementation="com.cordys.bre.ws.RuleService"> <classpath xmlns="http://schemas.cordys.com/1.0/xmlstore"> <location>/bin/bre.jar</location> </classpath> <component name="Rule Repository ConnectionPool"> <xmlEncoding>false</xmlEncoding> <precedence/> <cursorCacheSize>50</cursorCacheSize> <cursorCacheRefreshInterval>3600</cursorCacheRefreshInterval> <queryCacheSize>50</queryCacheSize> <queryCacheRefreshInterval>3600</queryCacheRefreshInterval> <maximumWriteConnections>5</maximumWriteConnections> <maximumReadConnections>5</maximumReadConnections> <minimumReadConnections>1</minimumReadConnections> <minimumWriteConnections>1</minimumWriteConnections> <connectionPoolRefreshInterval>3600</connectionPoolRefreshInterval> <multithreaded>true</multithreaded> <sharedPool>false</sharedPool> <xsiNilForNullData>false</xsiNilForNullData> <datasource> <type>Relational</type> <name>Cordys System#system</name> </datasource> <reconnectionAttempts>1</reconnectionAttempts> <requestThreshold>1000</requestThreshold> </component> <component name="Rule Engine"> <ruleAudit>false</ruleAudit> <threadPoolSize>5</threadPoolSize> <maxDispatcherQueueSize>50000</maxDispatcherQueueSize> </component> </configuration> </configurations>
RuleEngine ruleEngine = ruleEngineFactory.createRuleEngine(parentManagedComponent); OR Configuration ruleConfiguration = new Configuration(ruleConfigurationNode, parentManagedComponent); // This can be used for connecting by creating dso node instead of managed component. // If parentManagedComponent passed is null, this option is automatically set. ruleConfiguration.connectUsingDSO(); RuleEngineFactory ruleEngineFactory = RuleEngineFactory.getInstance(); RuleEngine ruleEngine = ruleEngineFactory.createRuleEngine(ruleConfiguration); OR RuleRepository ruleRepository = ruleEngineFactory.createRuleRepository(ruleConfiguration); RuleEngine ruleEngine = ruleEngineFactory.createRuleEngine(ruleRepository); //Additional behavior added to RuleEngine instance once it's initialized ruleEngine.setHostIdentifier("host framework name"); //For example, this can be coboc, bpm, wsapps, bam etc... ruleEngine.setAuditListner(new RuleAuditManager()); //required for publishing audit information to the host program. ruleEngine.setPreconditionProcessor(preProcessor); //preProcessor is an object of type com.cordys.bre.engine.PreconditionProcessor ruleEngine.registerActionHandlerClass("insert", com.cordys.coboc.ruleengine.action.InsertAction.class); ruleEngine.registerActionHandlerClass("update", com.cordys.coboc.ruleengine.action.UpdateAction.class); ruleEngine.registerActionHandlerClass("delete", com.cordys.coboc.ruleengine.action.DeleteAction.class); //the handler class for the action which is an implementation of com.cordys.bre.engine.Action class Then create a rule session, set user, object context and transaction context on the session, and execute rules RuleSession ruleSession = ruleEngine.createRuleSession(uriBinding, triggerType, triggerEvent); ruleSession.setUser(user); ruleSession.setTriggerObject(xObject); ruleSession.setTransactionContext(transaction); ruleSession.executeRules(); //Finally cleanup ruleSession.cleanUp();Also end the transaction passed to the rule session.
Modifier and Type | Method and Description |
---|---|
void |
closeRuleEngineResources()
This method should be called to close the system resource rule engine uses.
|
RuleSession |
createRuleSession()
Deprecated.
|
RuleSession |
createRuleSession(IRule[] rules)
Deprecated.
Use
createRuleSession(IRule[], String) Instead |
RuleSession |
createRuleSession(IRule[] rules,
java.lang.String user)
Create a
RuleSession for given set of Rules. |
RuleSession |
createRuleSession(java.lang.String decisionCaseId)
Deprecated.
Use
createRuleSession(String, String) Instead |
RuleSession |
createRuleSession(java.lang.String decisionCaseId,
java.lang.String user)
Create the
RuleSession for executing a particular decision
case. |
RuleSession |
createRuleSession(java.lang.String uriBinding,
java.lang.String ruleType,
int triggerEvent)
Deprecated.
Use
#createRuleSession(String, String, TriggerEvents, String, String) Instead |
RuleSession |
createRuleSession(java.lang.String uriBinding,
java.lang.String ruleType,
TriggerEvents event)
Deprecated.
|
RuleSession |
createRuleSession(java.lang.String uriBinding,
java.lang.String ruleType,
TriggerEvents event,
java.lang.String user)
Create the
RuleSession for the given URI binding between
the design time and the runtime. |
void |
disablePublishAudit()
Disables publish audit
|
void |
disableRuleAudit()
Disables the reporting of the rule execution with in the rule repository.
|
void |
enablePublishAudit()
Enables publish audit, when publish audit is enabled , rule engine will give rule monitor data to the AuditListner of host.
|
void |
enableRuleAudit()
Enables the reporting of the rule execution with in the rule repository.
|
Action |
getActionHandlerInstance(java.lang.String actionName,
int ruleActionNode,
IRule rule,
RuleSession ruleSession)
Creates an action handler instance for the given action name , action node, rule and rule session -use internal
|
AuditListner |
getAuditListner()
Gets the audit listener for the engine
|
java.lang.String |
getHostIdentifier()
This methods gets the host identifier
|
PreconditionProcessor |
getPreconditionProcessor()
Gets the precondition processor
|
RuleRepository |
getRuleRepository()
Returns the
RuleRepository associated with this
RuleEngine |
boolean |
isPublishAuditEnabled()
Retrieves the current publish audit state
|
boolean |
isRuleAuditEnabled()
Retrieves the current rule audit state
|
void |
registerActionHandlerClass(java.lang.String actionName,
java.lang.Class<? extends Action> clazz)
Registers an action handler class for the given action name.
|
void |
setAuditListner(AuditListner _auditListner)
Deprecated.
Use
#registerRuleMonitorListener(AuditListner) instead |
void |
setHostIdentifier(java.lang.String hostIdentifier)
This methods sets the host identifier, according to the which the configuration set up for the
host will be read and initialized.
|
void |
setPreconditionProcessor(PreconditionProcessor preConditionProcessor)
Sets the precondition processor
|
void |
unregisterActionHandlerClass(java.lang.String actionName)
Unregisters action handler class for given action name
|
java.lang.String getHostIdentifier()
void setHostIdentifier(java.lang.String hostIdentifier)
hostIdentifier
- - eg "coboc" , "wsappsserver" etc@Deprecated void setAuditListner(AuditListner _auditListner)
#registerRuleMonitorListener(AuditListner)
instead_auditListner
- AuditListner
AuditListner getAuditListner()
AuditListner
void enablePublishAudit()
void disablePublishAudit()
boolean isPublishAuditEnabled()
void enableRuleAudit()
void disableRuleAudit()
boolean isRuleAuditEnabled()
void registerActionHandlerClass(java.lang.String actionName, java.lang.Class<? extends Action> clazz) throws java.lang.NoSuchMethodException
actionName
- the unique identifier of the action which is the root tag name for the action defined in xmlClass
- the handler class for the action which is an implementation of Action
classjava.lang.NoSuchMethodException
void unregisterActionHandlerClass(java.lang.String actionName)
Action getActionHandlerInstance(java.lang.String actionName, int ruleActionNode, IRule rule, RuleSession ruleSession) throws java.lang.Exception
actionName
- the unique identifier of the action which is the root tag name for the action defined in xmlrule
- the rule IRule
to which the current action belongs toruleSession
- the rule session RuleSession
on which the action handler has to be created.java.lang.Exception
void setPreconditionProcessor(PreconditionProcessor preConditionProcessor)
preConditionProcessor
- PreconditionProcessor
PreconditionProcessor getPreconditionProcessor()
PreconditionProcessor
if one is set@Deprecated RuleSession createRuleSession(java.lang.String uriBinding, java.lang.String ruleType, TriggerEvents event)
createRuleSession(String, String, TriggerEvents, String)
insteadRuleSession
for the given URI binding between
the design time and the runtime.uriBinding
- the association of the design time rules to the runtime
ruleset.ruleType
- the type of rule applicable to this rule execution cycletriggerEvent
- com.cordys.bre.base.RuleTrigger.INSERT/
RuleTrigger.UPDATE/
RuleTrigger.DELETERuleSession createRuleSession(java.lang.String uriBinding, java.lang.String ruleType, TriggerEvents event, java.lang.String user)
RuleSession
for the given URI binding between
the design time and the runtime.uriBinding
- the association of the design time rules to the runtime
ruleset.ruleType
- the type of rule applicable to this rule execution cycletriggerEvent
- com.cordys.bre.base.RuleTrigger.INSERT/ RuleTrigger.UPDATE/
RuleTrigger.DELETEuser
- the user context for the current rule execution cycle. User
should be a valid LDAP user@Deprecated RuleSession createRuleSession(java.lang.String uriBinding, java.lang.String ruleType, int triggerEvent)
#createRuleSession(String, String, TriggerEvents, String, String)
InsteadRuleSession
for the given URI binding between
the design time and the runtime.uriBinding
- the association of the design time rules to the runtime
ruleset.ruleType
- the type of rule applicable to this rule execution cycletriggerEvent
- the type of the trigger applicable to this rule execution
cycle, the possible values are {1-INSERT/2-UPDATE/3-DELETE}@Deprecated RuleSession createRuleSession(IRule[] rules)
createRuleSession(IRule[], String)
InsteadRuleSession
for given set of Rules.rules
- the list of rules
defined on schema.RuleSession createRuleSession(IRule[] rules, java.lang.String user)
RuleSession
for given set of Rules.rules
- the list of rules
defined on schema.user
- the user context for the current rule execution cycle.User
should be a valid LDAP user@Deprecated RuleSession createRuleSession(java.lang.String decisionCaseId)
createRuleSession(String, String)
InsteadRuleSession
for executing a particular decision
case.decisionCaseId
- id of the decision case needs to be executedRuleSession createRuleSession(java.lang.String decisionCaseId, java.lang.String user)
RuleSession
for executing a particular decision
case.decisionCaseId
- id of the decision case needs to be executeduser
- the user context for the current rule execution cycle. User
should be a valid LDAP user@Deprecated RuleSession createRuleSession()
RuleSession
for executing rules, this
method is provided only for test cases.RuleRepository getRuleRepository()
RuleRepository
associated with this
RuleEngine
RuleRepository
configured to the database as given
in the Configuration
details.void closeRuleEngineResources()