@Override public void validate(KieSession ksession, Context<?> context) throws IllegalStateException { if (isClosed()) { throw new IllegalStateException("Runtime manager " + identifier + " is already closed"); } if (context == null || context.getContextId() == null) { return; } Long ksessionId = mapper.findMapping(context, this.identifier); if (ksessionId == null) { // make sure ksession is not use by any other context Object contextId = mapper.findContextId(ksession.getIdentifier(), this.identifier); if (contextId != null && !contextId.equals(context.getContextId().toString())) { throw new IllegalStateException("KieSession with id " + ksession.getIdentifier() + " is already used by another context " + contextId + " expected is "+ context.getContextId()); } return; } if (ksession.getIdentifier() != ksessionId) { throw new IllegalStateException("Invalid session was used for this context " + context); } }
@Override public Void execute(org.kie.api.runtime.Context context) { mapper.saveMapping(caseContext, ksessionId, ownerId); return null; } }
@Override public Void execute(org.kie.api.runtime.Context context) { mapper.removeMapping(caseContext, ownerId); return null; } }
public boolean validate(Long ksessionId, Long processInstanceId) { Long mapped = this.mapper.findMapping(ProcessInstanceIdContext.get(processInstanceId), this.identifier); if (Objects.equals(mapped, ksessionId)) { return true; } return false; }
@Override public void beforeProcessStarted(ProcessStartedEvent event) { String processId = event.getProcessInstance().getProcessId(); if (mapper.findContextId(ksessionId, getIdentifier()) == null) { //if no relation between process def ID and KIE Session is found, we store it mapper.saveMapping(ProcessDefContext.get(processId), ksessionId, getIdentifier()); } } }
public boolean validate(Long ksessionId, Long processInstanceId) { Long mapped = this.mapper.findMapping(ProcessInstanceIdContext.get(processInstanceId), this.identifier); if (Objects.equals(mapped, ksessionId)) { return true; } return false; }
ksessionId = mapper.findMapping(context, manager.getIdentifier()); if (ksessionId == null) { ksession = factory.newKieSession(); ksession.getEnvironment().set("CaseId", context.getContextId()); } else { Object contexts = mapper.findContextId(ksession.getIdentifier(), manager.getIdentifier()); if (contexts instanceof Collection) { KieSession finalKieSession = ksession;
@Override public void validate(KieSession ksession, Context<?> context) throws IllegalStateException { if (isClosed()) { throw new IllegalStateException("Runtime manager " + identifier + " is already closed"); } if (context == null || context.getContextId() == null) { return; } Long ksessionId = mapper.findMapping(context, this.identifier); if (ksessionId != null && ksession.getIdentifier() != ksessionId) { throw new IllegalStateException("Invalid session was used for this context " + context); } }
@Override public void beforeProcessStarted(ProcessStartedEvent event) { mapper.saveMapping(new EnvironmentAwareProcessInstanceContext(event.getKieRuntime().getEnvironment(), event.getProcessInstance().getId()), ksessionId, managerId); saveLocalRuntime(caseId, event.getProcessInstance().getId(), runtime); ((RuntimeEngineImpl) runtime).setContext(ProcessInstanceIdContext.get(event.getProcessInstance().getId())); }
@Override public void afterProcessCompleted(ProcessCompletedEvent event) { mapper.removeMapping(new EnvironmentAwareProcessInstanceContext(event.getKieRuntime().getEnvironment(), event.getProcessInstance().getId()), managerId); removeLocalRuntime(runtime, event.getProcessInstance().getId()); }
ksessionId = mapper.findMapping(context, this.identifier); if (ksessionId == null) { ksession = factory.newKieSession(); ksession.getEnvironment().set("CaseId", context.getContextId()); } else { Object contexts = mapper.findContextId(ksession.getIdentifier(), this.identifier); if (contexts instanceof Collection) { RuntimeEngine finalRuntimeEngnie = runtime; processInstanceId = (Long) contextId; Long ksessionId = mapper.findMapping(context, this.identifier); createLockOnGetEngine(ksessionId, runtime); saveLocalRuntime(caseId, processInstanceId, runtime);
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 beforeProcessStarted(ProcessStartedEvent event) { mapper.saveMapping(new EnvironmentAwareProcessInstanceContext( event.getKieRuntime().getEnvironment(), event.getProcessInstance().getId()), ksessionId, managerId); saveLocalRuntime(event.getProcessInstance().getId(), runtime); ((RuntimeEngineImpl)runtime).setContext(ProcessInstanceIdContext.get(event.getProcessInstance().getId())); createLockOnNewProcessInstance(event.getProcessInstance().getId(), runtime); }
@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()); }
@Override public void validate(KieSession ksession, Context<?> context) throws IllegalStateException { if (isClosed()) { throw new IllegalStateException("Runtime manager " + identifier + " is already closed"); } if (context == null || context.getContextId() == null) { return; } Long ksessionId = mapper.findMapping(context, this.identifier); if (ksessionId == null) { // make sure ksession is not use by any other context Object contextId = mapper.findContextId(ksession.getIdentifier(), this.identifier); if (contextId != null && !contextId.equals(context.getContextId().toString())) { throw new IllegalStateException("KieSession with id " + ksession.getIdentifier() + " is already used by another context " + contextId + " expected is "+ context.getContextId()); } return; } if (ksession.getIdentifier() != ksessionId) { throw new IllegalStateException("Invalid session was used for this context " + context); } }
Long found = mapper.findMapping(context, manager.getIdentifier()); if (found == null) { removeLocalRuntime(engine); return localRuntime.getKieSession(); ksessionId = mapper.findMapping(context, manager.getIdentifier()); if (ksessionId == null) { throw new SessionNotFoundException("No session found for context " + context.getContextId());
@Override public Void execute(org.kie.api.runtime.Context context) { mapper.saveMapping(caseContext, ksessionId, ownerId); return null; } }
@Override public Void execute(org.kie.api.runtime.Context context) { mapper.removeMapping(caseContext, ownerId); return null; } }
ksessionId = mapper.findMapping(context, manager.getIdentifier()); if (ksessionId == null) { ksession = factory.newKieSession(); ksession.getEnvironment().set("CaseId", context.getContextId()); } else { Object contexts = mapper.findContextId(ksession.getIdentifier(), manager.getIdentifier()); if (contexts instanceof Collection) { KieSession finalKieSession = ksession;
return localRuntime; ksessionId = mapper.findMapping(context, this.identifier); if (ksessionId == null) { throw new SessionNotFoundException("No session found for context " + context.getContextId());