use of org.jbpm.runtime.manager.impl.tx.DestroySessionTransactionSynchronization in project jbpm by kiegroup.
the class PerRequestRuntimeManager method getRuntimeEngine.
@Override
public RuntimeEngine getRuntimeEngine(Context<?> context) {
if (isClosed()) {
throw new IllegalStateException("Runtime manager " + identifier + " is already closed");
}
checkPermission();
RuntimeEngine runtime = null;
if (local.get().get(identifier) != null) {
RuntimeEngine engine = local.get().get(identifier);
// check if engine is not already disposed as afterCompletion might be issued from another thread
if (engine != null && ((RuntimeEngineImpl) engine).isDisposed()) {
return null;
}
return engine;
}
if (engineInitEager) {
InternalTaskService internalTaskService = newTaskService(taskServiceFactory);
runtime = new RuntimeEngineImpl(factory.newKieSession(), internalTaskService);
((RuntimeEngineImpl) runtime).setManager(this);
configureRuntimeOnTaskService(internalTaskService, runtime);
registerDisposeCallback(runtime, new DisposeSessionTransactionSynchronization(this, runtime), runtime.getKieSession().getEnvironment());
registerDisposeCallback(runtime, new DestroySessionTransactionSynchronization(runtime.getKieSession()), runtime.getKieSession().getEnvironment());
registerItems(runtime);
attachManager(runtime);
} else {
runtime = new RuntimeEngineImpl(context, new PerRequestInitializer());
((RuntimeEngineImpl) runtime).setManager(this);
}
local.get().put(identifier, runtime);
return runtime;
}
Aggregations