@Override public void close() { try { if (!(taskServiceFactory instanceof LocalTaskServiceFactory)) { // if it's CDI based (meaning single application scoped bean) we need to unregister context removeRuntimeFromTaskService(); } } catch(Exception e) { // do nothing } super.close(); factory.close(); }
ksession = factory.newKieSession(); ksessionId = ksession.getIdentifier(); if (context instanceof CaseContext) { ksession = factory.findKieSessionById(ksessionId);
KieSession initialKsession = factory.newKieSession(); factory.onDispose(initialKsession.getIdentifier()); initialKsession.execute(new DestroyKSessionCommand(initialKsession, this)); List<Long> ksessionsToInit = ((JPAMapper) mapper).findKSessionToInit(this.identifier); for (Long id : ksessionsToInit) { initialKsession = factory.findKieSessionById(id); initialKsession.execute(new DisposeKSessionCommand(initialKsession, this));
public void destroyCase(CaseContext caseContext) { KieSession kieSession = null; RuntimeEngine localRuntime = findLocalRuntime(caseContext.getContextId()); if (localRuntime != null) { kieSession = localRuntime.getKieSession(); } else { Long ksessionId = mapper.findMapping(caseContext, this.identifier); if (ksessionId != null) { kieSession = factory.findKieSessionById(ksessionId); } } factory.onDispose(kieSession.getIdentifier()); List<ExecutableCommand<?>> cmds = new ArrayList<>(); RemoveMappingCommand removeMapping = new RemoveMappingCommand(mapper, caseContext, getIdentifier()); cmds.add(removeMapping); DestroyKSessionCommand destroy = new DestroyKSessionCommand(kieSession, this); cmds.add(destroy); BatchExecutionCommand batchCmd = new BatchExecutionCommandImpl(cmds); kieSession.execute(batchCmd); }
@Override public void activate() { super.activate(); // need to init one session to bootstrap all case - such as start timers KieSession initialKsession = factory.newKieSession(); initialKsession.execute(new DestroyKSessionCommand(initialKsession, this)); }
try { Long ksessionId = ((RuntimeEngineImpl)runtime).getKieSessionId(); factory.onDispose(ksessionId); if (canDestroy(runtime)) { runtime.getKieSession().destroy();
@Override public void activate() { super.activate(); // need to init one session to bootstrap all case - such as start timers KieSession initialKsession = factory.newKieSession(); initialKsession.execute(new DestroyKSessionCommand(initialKsession, this)); }
public void destroyCase(CaseContext caseContext) { KieSession kieSession = null; RuntimeEngine localRuntime = findLocalRuntime(caseContext.getContextId()); if (localRuntime != null) { kieSession = localRuntime.getKieSession(); } else { Long ksessionId = mapper.findMapping(caseContext, this.identifier); if (ksessionId != null) { kieSession = factory.findKieSessionById(ksessionId); } } factory.onDispose(kieSession.getIdentifier()); List<ExecutableCommand<?>> cmds = new ArrayList<>(); RemoveMappingCommand removeMapping = new RemoveMappingCommand(mapper, caseContext, getIdentifier()); cmds.add(removeMapping); DestroyKSessionCommand destroy = new DestroyKSessionCommand(kieSession, this); cmds.add(destroy); BatchExecutionCommand batchCmd = new BatchExecutionCommandImpl(cmds); kieSession.execute(batchCmd); }
@Override public void afterProcessCompleted(ProcessCompletedEvent event) { mapper.removeMapping(new EnvironmentAwareProcessInstanceContext( event.getKieRuntime().getEnvironment(), event.getProcessInstance().getId()), managerId); factory.onDispose(runtime.getKieSession().getIdentifier()); registerDisposeCallback(runtime, new DestroySessionTransactionSynchronization(runtime.getKieSession()), runtime.getKieSession().getEnvironment()); }
ksessionId = mapper.findMapping(context, this.identifier); if (ksessionId == null) { ksession = factory.newKieSession(); ksessionId = ksession.getIdentifier(); ksession = factory.findKieSessionById(ksessionId);
KieSession initialKsession = factory.newKieSession(); factory.onDispose(initialKsession.getIdentifier()); initialKsession.execute(new DestroyKSessionCommand(initialKsession, this)); List<Long> ksessionsToInit = ((JPAMapper) mapper).findKSessionToInit(this.identifier); for (Long id : ksessionsToInit) { initialKsession = factory.findKieSessionById(id); initialKsession.execute(new DisposeKSessionCommand(initialKsession, this));
@Override public KieSession initKieSession(Context<?> context, InternalRuntimeManager manager, RuntimeEngine engine) { RuntimeEngine inUse = local.get().get(identifier); if (inUse != null && ((RuntimeEngineImpl) inUse).internalGetKieSession() != null) { return inUse.getKieSession(); } KieSession ksession = factory.newKieSession(); ((RuntimeEngineImpl)engine).internalSetKieSession(ksession); registerDisposeCallback(engine, new DisposeSessionTransactionSynchronization(manager, engine), ksession.getEnvironment()); registerDisposeCallback(engine, new DestroySessionTransactionSynchronization(ksession), ksession.getEnvironment()); registerItems(engine); attachManager(engine); return ksession; }
@Override public void close() { try { if (!(taskServiceFactory instanceof LocalTaskServiceFactory)) { // if it's CDI based (meaning single application scoped bean) we need to unregister context removeRuntimeFromTaskService(); } } catch(Exception e) { // do nothing } super.close(); factory.close(); }
try { Long ksessionId = ((RuntimeEngineImpl)runtime).getKieSessionId(); factory.onDispose(ksessionId); if (canDestroy(runtime)) { runtime.getKieSession().destroy();
Long ksessionId = null; if (contextId == null || context instanceof EmptyContext) { ksession = factory.newKieSession(); ksessionId = ksession.getIdentifier(); } else { throw new SessionNotFoundException("No session found for context " + context.getContextId()); ksession = factory.findKieSessionById(ksessionId);
KieSession initialKsession = factory.newKieSession(); factory.onDispose(initialKsession.getIdentifier()); initialKsession.execute(new DestroyKSessionCommand(initialKsession, this)); List<Long> ksessionsToInit = ((JPAMapper) mapper).findKSessionToInit(this.identifier); for (Long id : ksessionsToInit) { initialKsession = factory.findKieSessionById(id); initialKsession.execute(new DisposeKSessionCommand(initialKsession, this));
runtime = new RuntimeEngineImpl(factory.newKieSession(), internalTaskService); ((RuntimeEngineImpl) runtime).setManager(this);
@Override public void close() { try { if (!(taskServiceFactory instanceof LocalTaskServiceFactory)) { // if it's CDI based (meaning single application scoped bean) we need to unregister context removeRuntimeFromTaskService(); } } catch (Exception e) { // do nothing } super.close(); factory.close(); }
@Override public void afterProcessCompleted(ProcessCompletedEvent event) { mapper.removeMapping(new EnvironmentAwareProcessInstanceContext( event.getKieRuntime().getEnvironment(), event.getProcessInstance().getId()), managerId); factory.onDispose(runtime.getKieSession().getIdentifier()); registerDisposeCallback(runtime, new DestroySessionTransactionSynchronization(runtime.getKieSession()), runtime.getKieSession().getEnvironment()); }
if (knownSessionId > 0) { try { this.singleton = new SynchronizedRuntimeImpl(factory.findKieSessionById(knownSessionId), internalTaskService); } catch (RuntimeException e) { this.singleton = new SynchronizedRuntimeImpl(factory.newKieSession(), internalTaskService); persistSessionId(location, identifier, singleton.getKieSession().getIdentifier());