com.haley.haleyrules
Interface ExecutionListener
- All Superinterfaces:
- java.util.EventListener
- public interface ExecutionListener
- extends java.util.EventListener
The ExecutionListener interface allows an object to receive a message from Eclipse immediately before a rule is executed.
An implementation of ExecutionListener can be added to a KnowledgeBase to receive these messages,
see
The following code demonstrates the use of an ExecutionListener.
class MyExecutionListener implements ExecutionListener {
KnowledgeBase kb;
MyExecutionListener(KnowledgeBase kb) {
this.kb=kb;
// constructor
public void onExecutionActivation(WorkingMemory wm, Activation activation) {
Rule rule = null;
try {
rule = activation.getRule();
System.err.println("Rule " + rule.getName() +
" fired, with label " + rule.getLabel() +
", id = " + rule.getId() +
", salience = " + rule.getSalience());
} catch (EclipseException ee) {
ee.printStackTrace();
return;
} finally {
rule.release();
}
}
} // class MyExecutionListener
Then, your initialization code can use the listener as follows:
kb.setExecutionListener(new MyExecutionListener(kb));
- Author:
- The Haley Enterprise
Copyright © 1998-2004, all rights reserved.
Questions, comments or to report a problem contact
support@haley.com
- See Also:
KnowledgeBaseFactory.newKnowledgeBase(boolean, ErrorListener,Object),
KnowledgeBase.setExecutionListener(ExecutionListener)
onExecuteActivation
public void onExecuteActivation(WorkingMemory wm,
Activation activation)
throws EclipseException
- This method is called immediately before executing a rule.
- Parameters:
wm - the WorkingMemory executing this ruleactivation - the address of the activation (which will not survive after the listener(s) return)
- Throws:
EclipseException- See Also:
Activation.getRule()
Copyright © 1998-2006 Haley Systems, Inc. All Rights Reserved.