Search in sources :

Example 1 with InternalMapper

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

the class PerCaseRuntimeManager method signalEvent.

@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());
            }
        }
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) InternalMapper(org.jbpm.runtime.manager.impl.mapper.InternalMapper) ProcessInstanceIdContext(org.kie.internal.runtime.manager.context.ProcessInstanceIdContext)

Example 2 with InternalMapper

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

the class PerProcessInstanceRuntimeManager method signalEvent.

@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);
    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);
        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());
            }
        }
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) InternalMapper(org.jbpm.runtime.manager.impl.mapper.InternalMapper) ProcessInstanceIdContext(org.kie.internal.runtime.manager.context.ProcessInstanceIdContext)

Aggregations

InternalMapper (org.jbpm.runtime.manager.impl.mapper.InternalMapper)2 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)2 ProcessInstanceIdContext (org.kie.internal.runtime.manager.context.ProcessInstanceIdContext)2