use of org.kie.api.runtime.manager.RuntimeEngine in project jbpm by kiegroup.
the class UserTaskServiceImpl method execute.
@Override
public <T> T execute(String deploymentId, Command<T> command) {
Long processInstanceId = CommonUtils.getProcessInstanceId(command);
RuntimeManager manager = getRuntimeManager(deploymentId, command);
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
return taskService.execute(command);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.kie.api.runtime.manager.RuntimeEngine in project jbpm by kiegroup.
the class UserTaskServiceImpl method getCommentById.
@Override
public Comment getCommentById(String deploymentId, Long taskId, Long commentId) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
validateTask(deploymentId, taskId, task);
RuntimeManager manager = getRuntimeManager(task);
if (manager == null) {
logger.warn("Cannot find runtime manager for task {}", taskId);
return null;
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
return ((InternalTaskService) taskService).getCommentById(commentId);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.kie.api.runtime.manager.RuntimeEngine in project jbpm by kiegroup.
the class AsyncContinuationSupportTest method testAsyncModeWithParallelGateway.
@Test(timeout = 10000)
public void testAsyncModeWithParallelGateway() throws Exception {
final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("EndProcess", 1);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-AsyncParallelGateway.bpmn2"), ResourceType.BPMN2).addEnvironmentEntry("ExecutorService", executorService).addEnvironmentEntry("AsyncMode", "true").registerableItemsFactory(new DefaultRegisterableItemsFactory() {
@Override
public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {
Map<String, WorkItemHandler> handlers = super.getWorkItemHandlers(runtime);
handlers.put("Rest", new SystemOutWorkItemHandler());
return handlers;
}
@Override
public List<ProcessEventListener> getProcessEventListeners(RuntimeEngine runtime) {
List<ProcessEventListener> listeners = super.getProcessEventListeners(runtime);
listeners.add(countDownListener);
return listeners;
}
}).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ProcessInstance processInstance = ksession.startProcess("TestProject.DemoProcess");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
long processInstanceId = processInstance.getId();
countDownListener.waitTillCompleted();
processInstance = runtime.getKieSession().getProcessInstance(processInstanceId);
assertNull(processInstance);
}
use of org.kie.api.runtime.manager.RuntimeEngine in project jbpm by kiegroup.
the class AsyncContinuationSupportTest method testAsyncParallelGateway.
@Test(timeout = 10000)
public void testAsyncParallelGateway() throws Exception {
final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("REST", 1);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-AsyncParallelGateway.bpmn2"), ResourceType.BPMN2).addEnvironmentEntry("ExecutorService", executorService).registerableItemsFactory(new DefaultRegisterableItemsFactory() {
@Override
public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {
Map<String, WorkItemHandler> handlers = super.getWorkItemHandlers(runtime);
handlers.put("Rest", new SystemOutWorkItemHandler());
return handlers;
}
@Override
public List<ProcessEventListener> getProcessEventListeners(RuntimeEngine runtime) {
List<ProcessEventListener> listeners = super.getProcessEventListeners(runtime);
listeners.add(countDownListener);
return listeners;
}
}).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ProcessInstance processInstance = ksession.startProcess("TestProject.DemoProcess");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
long processInstanceId = processInstance.getId();
countDownListener.waitTillCompleted();
processInstance = runtime.getKieSession().getProcessInstance(processInstanceId);
assertNull(processInstance);
// List<? extends NodeInstanceLog> logs = runtime.getAuditService().findNodeInstances(processInstanceId);
// assertNotNull(logs);
// assertEquals(8, logs.size());
}
use of org.kie.api.runtime.manager.RuntimeEngine in project jbpm by kiegroup.
the class AsyncContinuationSupportTest method testAsyncCallActivityTask.
@Test(timeout = 10000)
public void testAsyncCallActivityTask() throws Exception {
final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("CallActivity", 1);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("BPMN2-CallActivity.bpmn2"), ResourceType.BPMN2).addEnvironmentEntry("ExecutorService", executorService).registerableItemsFactory(new DefaultRegisterableItemsFactory() {
@Override
public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {
Map<String, WorkItemHandler> handlers = super.getWorkItemHandlers(runtime);
handlers.put("async", new SystemOutWorkItemHandler());
return handlers;
}
@Override
public List<ProcessEventListener> getProcessEventListeners(RuntimeEngine runtime) {
List<ProcessEventListener> listeners = super.getProcessEventListeners(runtime);
listeners.add(countDownListener);
return listeners;
}
}).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ProcessInstance processInstance = ksession.startProcess("ParentProcess");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
long processInstanceId = processInstance.getId();
countDownListener.waitTillCompleted();
processInstance = runtime.getKieSession().getProcessInstance(processInstance.getId());
assertNull(processInstance);
List<? extends NodeInstanceLog> logs = runtime.getAuditService().findNodeInstances(processInstanceId);
assertNotNull(logs);
assertEquals(6, logs.size());
}
Aggregations