Search in sources :

Example 1 with DestroySessionTransactionSynchronization

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;
}
Also used : DestroySessionTransactionSynchronization(org.jbpm.runtime.manager.impl.tx.DestroySessionTransactionSynchronization) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) DisposeSessionTransactionSynchronization(org.jbpm.runtime.manager.impl.tx.DisposeSessionTransactionSynchronization) InternalTaskService(org.kie.internal.task.api.InternalTaskService)

Aggregations

DestroySessionTransactionSynchronization (org.jbpm.runtime.manager.impl.tx.DestroySessionTransactionSynchronization)1 DisposeSessionTransactionSynchronization (org.jbpm.runtime.manager.impl.tx.DisposeSessionTransactionSynchronization)1 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)1 InternalTaskService (org.kie.internal.task.api.InternalTaskService)1