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 signalEvent(String type, Object event) { // first signal with new context in case there are start event with signal RuntimeEngine runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get()); runtimeEngine.getKieSession().signalEvent(type, event); if (canDispose(runtimeEngine)) { disposeRuntimeEngine(runtimeEngine); } // next find out all instances waiting for given event type List<String> processInstances = ((InternalMapper) mapper).findContextIdForEvent(type, getIdentifier()); for (String piId : processInstances) { runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get(Long.parseLong(piId))); runtimeEngine.getKieSession().signalEvent(type, event); if (canDispose(runtimeEngine)) { disposeRuntimeEngine(runtimeEngine); } } // process currently active runtime engines Map<Object, RuntimeEngine> currentlyActive = local.get(); if (currentlyActive != null && !currentlyActive.isEmpty()) { RuntimeEngine[] activeEngines = currentlyActive.values().toArray(new RuntimeEngine[currentlyActive.size()]); for (RuntimeEngine engine : activeEngines) { Context<?> context = ((RuntimeEngineImpl) engine).getContext(); if (context != null && context instanceof ProcessInstanceIdContext && ((ProcessInstanceIdContext) context).getContextId() != null) { engine.getKieSession().signalEvent(type, event, ((ProcessInstanceIdContext) context).getContextId()); } } } }
TimerService timerService = TimerServiceRegistry.getInstance().get(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX); if (timerService != null) { if (timerService instanceof GlobalTimerService) {
@Override public void init() { TaskContentRegistry.get().addMarshallerContext(getIdentifier(), new ContentMarshallerContext(environment.getEnvironment(), environment.getClassLoader())); boolean owner = false; TransactionManager tm = null;
ksession.execute(new SaveMappingCommand(mapper, context, ksessionId, getIdentifier()));
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 signalEvent(String type, Object event) { // first signal with new context in case there are start event with signal RuntimeEngine runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get()); runtimeEngine.getKieSession().signalEvent(type, event); if (canDispose(runtimeEngine)) { disposeRuntimeEngine(runtimeEngine); } // next find out all instances waiting for given event type List<String> processInstances = ((InternalMapper) mapper).findContextIdForEvent(type, getIdentifier()); for (String piId : processInstances) { runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get(Long.parseLong(piId))); runtimeEngine.getKieSession().signalEvent(type, event); if (canDispose(runtimeEngine)) { disposeRuntimeEngine(runtimeEngine); } } // process currently active runtime engines Map<Object, RuntimeEngine> currentlyActive = local.get(); if (currentlyActive != null && !currentlyActive.isEmpty()) { RuntimeEngine[] activeEngines = currentlyActive.values().toArray(new RuntimeEngine[currentlyActive.size()]); for (RuntimeEngine engine : activeEngines) { Context<?> context = ((RuntimeEngineImpl) engine).getContext(); if (context != null && context instanceof ProcessInstanceIdContext && ((ProcessInstanceIdContext) context).getContextId() != null) { engine.getKieSession().signalEvent(type, event, ((ProcessInstanceIdContext) context).getContextId()); } } } }
TimerService timerService = TimerServiceRegistry.getInstance().get(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX); if (timerService != null) { if (timerService instanceof GlobalTimerService) {
@Override public void init() { TaskContentRegistry.get().addMarshallerContext(getIdentifier(), new ContentMarshallerContext(environment.getEnvironment(), environment.getClassLoader())); boolean owner = false; TransactionManager tm = null;
ksession.execute(new SaveMappingCommand(mapper, context, ksessionId, getIdentifier()));