Search in sources :

Example 1 with ProcessRuntimeImpl

use of org.jbpm.process.instance.ProcessRuntimeImpl in project jbpm by kiegroup.

the class ProcessInstanceResolverStrategy method retrieveProcessInstanceManager.

/**
 * Retrieve the {@link ProcessInstanceManager} object from the ObjectOutput- or ObjectInputStream.
 * The stream object will secretly also either be a {@link MarshallerReaderContext} or a
 * {@link MarshallerWriteContext}.
 * @param streamContext The marshaller stream/context.
 * @return A {@link ProcessInstanceManager} object.
 */
public static ProcessInstanceManager retrieveProcessInstanceManager(Object streamContext) {
    ProcessInstanceManager pim = null;
    if (streamContext instanceof MarshallerWriteContext) {
        MarshallerWriteContext context = (MarshallerWriteContext) streamContext;
        pim = ((ProcessRuntimeImpl) ((InternalWorkingMemory) context.wm).getProcessRuntime()).getProcessInstanceManager();
    } else if (streamContext instanceof MarshallerReaderContext) {
        MarshallerReaderContext context = (MarshallerReaderContext) streamContext;
        pim = ((ProcessRuntimeImpl) ((InternalWorkingMemory) context.wm).getProcessRuntime()).getProcessInstanceManager();
    } else {
        throw new UnsupportedOperationException("Unable to retrieve " + ProcessInstanceManager.class.getSimpleName() + " from " + streamContext.getClass().getName());
    }
    return pim;
}
Also used : ProcessInstanceManager(org.jbpm.process.instance.ProcessInstanceManager) InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) MarshallerWriteContext(org.drools.core.marshalling.impl.MarshallerWriteContext) MarshallerReaderContext(org.drools.core.marshalling.impl.MarshallerReaderContext) ProcessRuntimeImpl(org.jbpm.process.instance.ProcessRuntimeImpl)

Example 2 with ProcessRuntimeImpl

use of org.jbpm.process.instance.ProcessRuntimeImpl in project jbpm by kiegroup.

the class InMemorySessionFactory method newKieSession.

@Override
public KieSession newKieSession() {
    Environment env = environment.getEnvironment();
    env.set(EnvironmentName.DEPLOYMENT_ID, owner);
    KieSession ksession = kbase.newKieSession(environment.getConfiguration(), env);
    this.sessions.put(ksession.getIdentifier(), ksession);
    ProcessInstanceManager piManager = ((ProcessRuntimeImpl) ((StatefulKnowledgeSessionImpl) ksession).getProcessRuntime()).getProcessInstanceManager();
    if (piManager instanceof DefaultProcessInstanceManager) {
        ((DefaultProcessInstanceManager) piManager).setProcessCounter(processCounter);
    }
    return ksession;
}
Also used : DefaultProcessInstanceManager(org.jbpm.process.instance.impl.DefaultProcessInstanceManager) ProcessInstanceManager(org.jbpm.process.instance.ProcessInstanceManager) ProcessRuntimeImpl(org.jbpm.process.instance.ProcessRuntimeImpl) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) Environment(org.kie.api.runtime.Environment) KieSession(org.kie.api.runtime.KieSession) DefaultProcessInstanceManager(org.jbpm.process.instance.impl.DefaultProcessInstanceManager)

Aggregations

ProcessInstanceManager (org.jbpm.process.instance.ProcessInstanceManager)2 ProcessRuntimeImpl (org.jbpm.process.instance.ProcessRuntimeImpl)2 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)1 MarshallerReaderContext (org.drools.core.marshalling.impl.MarshallerReaderContext)1 MarshallerWriteContext (org.drools.core.marshalling.impl.MarshallerWriteContext)1 DefaultProcessInstanceManager (org.jbpm.process.instance.impl.DefaultProcessInstanceManager)1 Environment (org.kie.api.runtime.Environment)1 KieSession (org.kie.api.runtime.KieSession)1 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)1