/** * 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; }
public ProcessRuntimeImpl(InternalKnowledgeRuntime kruntime) { this.kruntime = kruntime; TimerService timerService = kruntime.getTimerService(); if ( !(timerService.getTimerJobFactoryManager() instanceof CommandServiceTimerJobFactoryManager) ) { timerService.setTimerJobFactoryManager( new ThreadSafeTrackableTimeJobFactoryManager() ); } ((CompositeClassLoader) getRootClassLoader()).addClassLoader( getClass().getClassLoader() ); initProcessInstanceManager(); initSignalManager(); timerManager = new TimerManager(kruntime, kruntime.getTimerService()); processEventSupport = new ProcessEventSupport(); if (isActive()) { initProcessEventListeners(); initStartTimers(); } initProcessActivationListener(); }
public InternalProcessRuntime newProcessRuntime(InternalWorkingMemory workingMemory) { return new ProcessRuntimeImpl(workingMemory); }
public ProcessInstance startProcess(String processId, Map<String, Object> parameters, String trigger) { ProcessInstance processInstance = createProcessInstance(processId, parameters); if ( processInstance != null ) { // start process instance return startProcessInstance(processInstance.getId(), trigger); } return null; }
public ProcessInstance startProcessInstance(long processInstanceId, String trigger) { try { kruntime.startOperation(); ProcessInstance processInstance = getProcessInstance(processInstanceId); ((org.jbpm.process.instance.ProcessInstance) processInstance).configureSLA(); getProcessEventSupport().fireBeforeProcessStarted( processInstance, kruntime ); ((org.jbpm.process.instance.ProcessInstance) processInstance).start(trigger); getProcessEventSupport().fireAfterProcessStarted( processInstance, kruntime ); return processInstance; } finally { kruntime.endOperation(); } }
@Override public Void execute(org.kie.api.runtime.Context context) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); ksession.getEnvironment().set("Active", true); InternalProcessRuntime processRuntime = ((InternalKnowledgeRuntime) ksession).getProcessRuntime(); ((ProcessRuntimeImpl) processRuntime).initProcessEventListeners(); ((ProcessRuntimeImpl) processRuntime).initStartTimers(); return null; } });
public ProcessInstance getProcessInstance(long id) { return getProcessInstance( id, false ); }
public ProcessInstance createProcessInstance(String processId, Map<String, Object> parameters) { return createProcessInstance(processId, null, parameters); }
public void initProcessEventListeners() { for ( Process process : kruntime.getKieBase().getProcesses() ) { initProcessEventListener(process); } }
private Class<?> loadClass(String className) { try { return getRootClassLoader().loadClass(className); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
@Override public Void execute(org.kie.api.runtime.Context context) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); ksession.getEnvironment().set("Active", true); InternalProcessRuntime processRuntime = ((InternalKnowledgeRuntime) ksession).getProcessRuntime(); ((ProcessRuntimeImpl) processRuntime).initProcessEventListeners(); ((ProcessRuntimeImpl) processRuntime).initStartTimers(); return null; } });
@Override public ProcessInstance startProcess(String processId, CorrelationKey correlationKey, Map<String, Object> parameters) { ProcessInstance processInstance = createProcessInstance(processId, correlationKey, parameters); if ( processInstance != null ) { return startProcessInstance(processInstance.getId()); } return null; }
public ProcessInstance startProcessInstance(long processInstanceId, String trigger) { try { kruntime.startOperation(); ProcessInstance processInstance = getProcessInstance(processInstanceId); ((org.jbpm.process.instance.ProcessInstance) processInstance).configureSLA(); getProcessEventSupport().fireBeforeProcessStarted( processInstance, kruntime ); ((org.jbpm.process.instance.ProcessInstance) processInstance).start(trigger); getProcessEventSupport().fireAfterProcessStarted( processInstance, kruntime ); return processInstance; } finally { kruntime.endOperation(); } }
public void abortProcessInstance(long processInstanceId) { ProcessInstance processInstance = getProcessInstance(processInstanceId); if ( processInstance == null ) { throw new IllegalArgumentException( "Could not find process instance for id " + processInstanceId ); } ((org.jbpm.process.instance.ProcessInstance) processInstance).setState( ProcessInstance.STATE_ABORTED ); }
public ProcessInstance createProcessInstance(String processId, Map<String, Object> parameters) { return createProcessInstance(processId, null, parameters); }
public void initProcessEventListeners() { for ( Process process : kruntime.getKieBase().getProcesses() ) { initProcessEventListener(process); } }
private Class<?> loadClass(String className) { try { return getRootClassLoader().loadClass(className); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
public ProcessRuntimeImpl(InternalWorkingMemory workingMemory) { TimerService timerService = workingMemory.getTimerService(); if ( !(timerService.getTimerJobFactoryManager() instanceof CommandServiceTimerJobFactoryManager) ) { timerService.setTimerJobFactoryManager( new ThreadSafeTrackableTimeJobFactoryManager() ); } this.kruntime = (InternalKnowledgeRuntime) workingMemory.getKnowledgeRuntime(); initProcessInstanceManager(); initSignalManager(); timerManager = new TimerManager(kruntime, kruntime.getTimerService()); processEventSupport = new ProcessEventSupport(); if (isActive()) { initProcessEventListeners(); initStartTimers(); } initProcessActivationListener(); }
@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; }
@Override public ProcessInstance startProcess(String processId, CorrelationKey correlationKey, Map<String, Object> parameters) { ProcessInstance processInstance = createProcessInstance(processId, correlationKey, parameters); if ( processInstance != null ) { return startProcessInstance(processInstance.getId()); } return null; }