Search in sources :

Example 1 with InMemoryMapper

use of org.jbpm.runtime.manager.impl.mapper.InMemoryMapper in project jbpm by kiegroup.

the class PerCaseRuntimeManager method disposeRuntimeEngine.

@Override
public void disposeRuntimeEngine(RuntimeEngine runtime) {
    if (isClosed()) {
        throw new IllegalStateException("Runtime manager " + identifier + " is already closed");
    }
    try {
        if (canDispose(runtime)) {
            removeLocalRuntime(runtime);
            Long ksessionId = ((RuntimeEngineImpl) runtime).getKieSessionId();
            releaseAndCleanLock(ksessionId, runtime);
            if (runtime instanceof Disposable) {
                // special handling for in memory to not allow to dispose if there is any context in the mapper
                if (mapper instanceof InMemoryMapper && ((InMemoryMapper) mapper).hasContext(ksessionId)) {
                    return;
                }
                ((Disposable) runtime).dispose();
            }
            if (ksessionId != null) {
                TimerService timerService = TimerServiceRegistry.getInstance().get(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX);
                if (timerService != null) {
                    if (timerService instanceof GlobalTimerService) {
                        ((GlobalTimerService) timerService).clearTimerJobInstances(ksessionId);
                    }
                }
            }
        }
    } catch (Exception e) {
        releaseAndCleanLock(runtime);
        removeLocalRuntime(runtime);
        throw new RuntimeException(e);
    }
}
Also used : Disposable(org.kie.internal.runtime.manager.Disposable) InMemoryMapper(org.jbpm.runtime.manager.impl.mapper.InMemoryMapper) GlobalTimerService(org.jbpm.process.core.timer.impl.GlobalTimerService) TimerService(org.drools.core.time.TimerService) GlobalTimerService(org.jbpm.process.core.timer.impl.GlobalTimerService)

Example 2 with InMemoryMapper

use of org.jbpm.runtime.manager.impl.mapper.InMemoryMapper in project jbpm by kiegroup.

the class PerProcessInstanceRuntimeManager method disposeRuntimeEngine.

@Override
public void disposeRuntimeEngine(RuntimeEngine runtime) {
    if (isClosed()) {
        throw new IllegalStateException("Runtime manager " + identifier + " is already closed");
    }
    try {
        if (canDispose(runtime)) {
            removeLocalRuntime(runtime);
            Long ksessionId = ((RuntimeEngineImpl) runtime).getKieSessionId();
            if (runtime instanceof Disposable) {
                // special handling for in memory to not allow to dispose if there is any context in the mapper
                if (mapper instanceof InMemoryMapper && ((InMemoryMapper) mapper).hasContext(ksessionId)) {
                    return;
                }
                ((Disposable) runtime).dispose();
            }
            if (ksessionId != null) {
                TimerService timerService = TimerServiceRegistry.getInstance().get(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX);
                if (timerService != null) {
                    if (timerService instanceof GlobalTimerService) {
                        ((GlobalTimerService) timerService).clearTimerJobInstances(ksessionId);
                    }
                }
            }
            releaseAndCleanLock(runtime);
        }
    } catch (Exception e) {
        releaseAndCleanLock(runtime);
        removeLocalRuntime(runtime);
        throw new RuntimeException(e);
    }
}
Also used : Disposable(org.kie.internal.runtime.manager.Disposable) InMemoryMapper(org.jbpm.runtime.manager.impl.mapper.InMemoryMapper) GlobalTimerService(org.jbpm.process.core.timer.impl.GlobalTimerService) TimerService(org.drools.core.time.TimerService) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException) GlobalTimerService(org.jbpm.process.core.timer.impl.GlobalTimerService)

Aggregations

TimerService (org.drools.core.time.TimerService)2 GlobalTimerService (org.jbpm.process.core.timer.impl.GlobalTimerService)2 InMemoryMapper (org.jbpm.runtime.manager.impl.mapper.InMemoryMapper)2 Disposable (org.kie.internal.runtime.manager.Disposable)2 SessionNotFoundException (org.kie.internal.runtime.manager.SessionNotFoundException)1