You need to pass an Agenda Filter to the runRules() method that will filter
which rules are allowed to run.
For example..
public class MyAgendaFilter implements AgendaFilter {
/** List of rule names to be allowed to fired*/
ArrayList<String> rulesToFire;
public MyAgendaFilter() {
rulesToFire = new ArrayList<String>();
}
/**
* Adds a rule to list of rules to be allowed to fire
* @param name Name of rule to be fired
*/
public void addRuleToFire(String name) {
rulesToFire.add(name);
}
@Override
public boolean accept(Activation activation) {
if (rulesToFire.contains(activation.getRule().getName())) {
return true;
} else {
return false;
}
}
}
This can then be used as follows:
AgendaFilter filter = new MyAgendaFilter();
filter.addRuleToFire("Rule Name");
StatefulKnowledgeSession knowledgeSession =
kbase.newStatefulKnowledgeSession();
knowledgeSession.fireAllRules(filter);
--
View this message in context:
http://drools.46999.n3.nabble.com/How-to-dynamic-remove-or-add-the-rules-...
Sent from the Drools: User forum mailing list archive at
Nabble.com.