}
public void FIXMEtestTimer() {
AbstractRuleBase ruleBase = (AbstractRuleBase) RuleBaseFactory.newRuleBase();
ExecutorService executorService = new DefaultExecutorService();
final StatefulSession workingMemory = new ReteooStatefulSession(1, ruleBase, executorService);
executorService.setCommandExecutor( new CommandExecutor( workingMemory ) );
RuleFlowProcessInstance processInstance = new RuleFlowProcessInstance() {
private static final long serialVersionUID = 510l;
public void signalEvent(String type, Object event) {
if ("timerTriggered".equals(type)) {
TimerInstance timer = (TimerInstance) event;
System.out.println("Timer " + timer.getId() + " triggered");
counter++;
}
}
};
processInstance.setKnowledgeRuntime(((InternalWorkingMemory) workingMemory).getKnowledgeRuntime());
processInstance.setId(1234);
((InternalProcessRuntime) ((InternalWorkingMemory) workingMemory).getProcessRuntime()).getProcessInstanceManager()
.internalAddProcessInstance(processInstance);
new Thread(new Runnable() {
public void run() {
workingMemory.fireUntilHalt();
}
}).start();
TimerManager timerManager = ((InternalProcessRuntime) ((InternalWorkingMemory) workingMemory).getProcessRuntime()).getTimerManager();
TimerInstance timer = new TimerInstance();