use of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession in project jbpm by kiegroup.
the class TimerCycleOnBinaryPackageTest method testStartTimerCycleFromDiscDRL.
@Test
@Ignore("beta4 phreak")
public void testStartTimerCycleFromDiscDRL() throws Exception {
KieBase kbase = createKnowledgeBaseFromDisc("rules-timer.drl");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
long sessionId = ksession.getIdentifier();
Environment env = ksession.getEnvironment();
final List<String> list = new ArrayList<String>();
ksession.setGlobal("list", list);
((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession().addEventListener(new TriggerRulesEventListener(ksession));
ksession.fireAllRules();
Thread.sleep(5000);
assertEquals(2, list.size());
logger.info("dispose");
ksession.dispose();
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env);
AuditLoggerFactory.newInstance(Type.JPA, ksession, null);
final List<String> list2 = new ArrayList<String>();
ksession.setGlobal("list", list2);
((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession().addEventListener(new TriggerRulesEventListener(ksession));
ksession.fireAllRules();
Thread.sleep(6000);
assertEquals(3, list2.size());
}
use of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession in project jbpm by kiegroup.
the class ActivityTest method testRuleTaskWithFactsWithPersistence.
@Test
@RequirePersistence
public void testRuleTaskWithFactsWithPersistence() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-RuleTaskWithFact.bpmn2", "BPMN2-RuleTask3.drl");
ksession = createKnowledgeSession(kbase);
((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession().addEventListener(new TriggerRulesEventListener(ksession));
ksession.addEventListener(new DebugAgendaEventListener());
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "SomeString");
ProcessInstance processInstance = ksession.startProcess("RuleTask", params);
assertProcessInstanceFinished(processInstance, ksession);
params = new HashMap<String, Object>();
try {
processInstance = ksession.startProcess("RuleTask", params);
fail("Should fail");
} catch (Exception e) {
e.printStackTrace();
}
params = new HashMap<String, Object>();
params.put("x", "SomeString");
processInstance = ksession.startProcess("RuleTask", params);
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession in project jahia by Jahia.
the class JBPM6WorkflowProvider method executeCommand.
private <T> T executeCommand(BaseCommand<T> t) {
t.setRuntimeEngine(runtimeEngine);
t.setEm(sharedEm);
t.setPersistenceManager(jbpmServicesPersistenceManager);
t.setGroupManager(groupManager);
t.setUserManager(userManager);
t.setWorkflowService(workflowService);
t.setKey(key);
CommandBasedStatefulKnowledgeSession s = (CommandBasedStatefulKnowledgeSession) runtimeEngine.getKieSession();
return s.execute(t);
}
Aggregations