private void addEventListenersToSession(StatefulKnowledgeSession session) { session.addEventListener(new DefaultProcessEventListener() { @Override public void afterProcessStarted(ProcessStartedEvent event) { logger.info(">>> Firing All the Rules after process started! " + event); ((StatefulKnowledgeSession) event.getKieRuntime()).fireAllRules(); } }); }
@Override public void dispose() { for (Map.Entry<String, Object> entry : cache.entrySet()) { if (entry.getValue() instanceof Cacheable) { ((Cacheable) entry.getValue()).close(); } } cache.clear(); }
@After public void dispose() { if (ksession != null) { ksession.dispose(); ksession = null; } }
public Integer execute(Context context) { StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) ((RegistryContext) context).lookup( KieSession.class ); WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.getProcessInstance(piId); return (Integer) processInstance.getVariable("x"); } });
@Override public void afterProcessStarted(ProcessStartedEvent event) { logger.info(">>> Firing All the Rules after process started! " + event); ((StatefulKnowledgeSession) event.getKieRuntime()).fireAllRules(); } });
@Test public void testResourceType() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-MinimalProcess.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.startProcess("Minimal"); }
private String getRuleSetEventType() { InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); if (kruntime instanceof StatefulKnowledgeSession) { return "RuleFlowGroup_" + getRuleFlowGroup() + "_" + ((StatefulKnowledgeSession) kruntime).getIdentifier(); } else { return "RuleFlowGroup_" + getRuleFlowGroup(); } }
@After public void dispose() { if (ksession != null) { ksession.dispose(); ksession = null; } }
public Void execute(Context context) { StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) ((RegistryContext) context).lookup( KieSession.class ); WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.getProcessInstance(piId); processInstance.setVariable("x", 0); return null; } });
@Test public void testEscalationEndEventProcess() throws Exception { KieBase kbase = createKnowledgeBase("escalation/BPMN2-EscalationEndEvent.bpmn2"); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); ProcessInstance processInstance = ksession .startProcess("EscalationEndEvent"); assertProcessInstanceAborted(processInstance); }
private StatefulKnowledgeSession reloadKnowledgeSession(StatefulKnowledgeSession ksession) { ksession.dispose(); return reloadKnowledgeSession(); } }
/** * Helper functions */ private void assertProcessInstancesExist(long[] processId) { StatefulKnowledgeSession ksession = reloadKnowledgeSession(); for (long id : processId) { assertNotNull("Process instance " + id + " should not exist!", ksession.getProcessInstance(id)); } }
@Test public void testImplicitEndParallel() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-ParallelSplit.bpmn2"); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); ProcessInstance processInstance = ksession.startProcess("com.sample.test"); assertProcessInstanceCompleted(processInstance); }
@After public void dispose() { if (ksession != null) { ksession.dispose(); } }
public Void execute(Context context) { StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) ((RegistryContext) context).lookup( KieSession.class ); ((ProcessInstanceImpl) ksession.getProcessInstance(processInstance.getId())).updateProcess(process); return null; } });
@Test public void testImport() throws Exception { KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-Import.bpmn2"); ksession = createKnowledgeSession(kbase); ProcessInstance processInstance = ksession.startProcess("Import"); assertProcessInstanceCompleted(processInstance); }
@After public void dispose() { if (ksession != null) { ksession.dispose(); ksession = null; } }
@After public void after() { if( ksession != null ) { ksession.dispose(); } cleanUp(context); }
@Override protected StatefulKnowledgeSession disposeAndReloadSession(StatefulKnowledgeSession ksession, long ksessionId, KieBase kbase) { ksession.dispose(); return JPAKnowledgeService.loadStatefulKnowledgeSession( ksessionId, kbase, null, createEnvironment(context) ); }
@After public void after() { if (ksession != null) { ksession.dispose(); } cleanUp(context); }