本文整理匯總了Java中org.activiti.engine.RuntimeService類的典型用法代碼示例。如果您正苦於以下問題:Java RuntimeService類的具體用法?Java RuntimeService怎麽用?Java RuntimeService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RuntimeService類屬於org.activiti.engine包,在下文中一共展示了RuntimeService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startProcess
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
@Test
public void startProcess() throws Exception {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("confirmPublish", "N");
String processId = "Employee360DegreeFeedbackProjectPublishProcess";
RuntimeService runtimeService = (RuntimeService) AppContext.getBean("runtimeService");
ProcessInstance process = runtimeService.startProcessInstanceByKey(processId, paramMap);
System.out.println("DeploymentId: " + process.getDeploymentId() );
System.out.println("ActivityId: " + process.getActivityId() );
System.out.println("Name: " + process.getName() );
System.out.println("ProcessDefinitionId: " + process.getProcessDefinitionId());
System.out.println("ProcessDefinitionKey: " + process.getProcessDefinitionKey());
System.out.println("ProcessDefinitionName: " + process.getProcessDefinitionName());
System.out.println("BusinessKey: " + process.getBusinessKey());
}
示例2: testSend
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
@Deployment
public void testSend() {
ProcessEngine processEngine = muleContext.getRegistry().get("processEngine");
TestHelper.annotationDeploymentSetUp(processEngine, getClass(), getName());
RuntimeService runtimeService = muleContext.getRegistry().get("runtimeService");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
assertFalse(processInstance.isEnded());
Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
assertEquals(10, result);
}
示例3: triggerSignalEvent
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
/**
* Trigger a signal event on all executions for a specific business key.
*
* @see <a href="http://www.activiti.org/userguide/index.html#bpmnSignalEventDefinition" />
* @see CoreSignals
*/
protected void triggerSignalEvent(ProcessEngine processEngine, String businessKey, String signalName) {
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceBusinessKey(businessKey).singleResult();
List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(processInstance.getProcessInstanceId())
.signalEventSubscriptionName(signalName).list();
if (executions.isEmpty()) {
throw new NoSuchElementException(String.format("No executions found waiting " +
"for signal '%s' on process %s", signalName, businessKey));
}
for (Execution execution : executions) {
LOG.info("Sending '{}' signal to execution {} for process {}",
new Object[]{signalName, execution.getId(), businessKey});
runtimeService.signalEventReceived(signalName, execution.getId());
}
}
示例4: getEngineServices
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
@Override
public EngineServices getEngineServices() {
if (this.engineServicesMock != null) {
return this.engineServicesMock;
}
this.engineServicesMock = mock(EngineServices.class);
when(engineServicesMock.getFormService()).thenReturn(mock(FormService.class));
when(engineServicesMock.getHistoryService()).thenReturn(mock(HistoryService.class));
when(engineServicesMock.getIdentityService()).thenReturn(mock(IdentityService.class));
when(engineServicesMock.getManagementService()).thenReturn(mock(ManagementService.class));
when(engineServicesMock.getRepositoryService()).thenReturn(mock(RepositoryService.class));
when(engineServicesMock.getRuntimeService()).thenReturn(mock(RuntimeService.class));
when(engineServicesMock.getTaskService()).thenReturn(mock(TaskService.class));
return engineServicesMock;
}
示例5: setUp
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
@BeforeTest
public void setUp(){
RuntimeService rts = mock(RuntimeService.class);
List<ProcessInstance> processList = new ArrayList<ProcessInstance>();
ExecutionEntity executionEntity = new ExecutionEntity();
executionEntity.setActive(false);
processList.add(executionEntity);
ProcessInstanceQuery pQuery = mock(ProcessInstanceQuery.class);
when(pQuery.active()).thenReturn(pQuery);
when(pQuery.list()).thenReturn(processList);
when(rts.createProcessInstanceQuery()).thenReturn(pQuery);
this.servlet.setRuntimeService(rts);
this.servlet.setWoDispatcher(mock(WoDispatcher.class));
this.servlet.init();
}
示例6: stopProcessInstance
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
public void stopProcessInstance(String instanceId, String username, OperationResult parentResult) {
OperationResult result = parentResult.createSubresult(OPERATION_STOP_PROCESS_INSTANCE);
result.addParam("instanceId", instanceId);
RuntimeService rs = activitiEngine.getRuntimeService();
try {
LOGGER.trace("Stopping process instance {} on the request of {}", instanceId, username);
String deletionMessage = "Process instance stopped on the request of " + username;
rs.setVariable(instanceId, CommonProcessVariableNames.VARIABLE_PROCESS_INSTANCE_IS_STOPPING, Boolean.TRUE);
rs.deleteProcessInstance(instanceId, deletionMessage);
} catch (RuntimeException e) {
result.recordFatalError("Process instance couldn't be stopped: " + e.getMessage(), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
示例7: execute
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
public void execute(DelegateExecution execution) {
if (LOGGER.isTraceEnabled()) {
RuntimeService runtimeService = execution.getEngineServices().getRuntimeService();
Set<String> variablesSeen = new HashSet<>();
LOGGER.trace("--------------------------------- DumpVariables: " + execution.getCurrentActivityId());
// LOGGER.trace("All variables for execution id={}, parent id={}", execution.getId(), execution.getParentId());
// execution.getVariableInstances().forEach((n, v) -> LOGGER.trace(" - {} = {} (in {})", n, v.getValue(), v.getExecutionId()));
LOGGER.trace("Execution hierarchy for id={}", execution.getId());
LOGGER.trace("------------------------------------");
dumpExecutionVariables(execution.getId(), execution, null, variablesSeen, runtimeService);
Collection<String> disjunction = CollectionUtils.disjunction(variablesSeen, execution.getVariableNames());
if (!disjunction.isEmpty()) {
LOGGER.trace("*** Variables not found in execution tree or 'execution.getVariableNames()': {}", disjunction);
}
LOGGER.trace("--------------------------------- DumpVariables: " + execution.getCurrentActivityId() + " END ------------");
}
}
示例8: testStartProcess
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
@Test
public void testStartProcess() throws Exception {
// 創建流程引擎,使用內存數據庫
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneInMemProcessEngineConfiguration()
.buildProcessEngine();
// 部署流程定義文件
RepositoryService repositoryService = processEngine.getRepositoryService();
String processFileName = "me/kafeitu/activiti/helloworld/sayhelloleave.bpmn";
repositoryService.createDeployment().addClasspathResource(processFileName)
.deploy();
// 驗證已部署流程定義
ProcessDefinition processDefinition = repositoryService
.createProcessDefinitionQuery().singleResult();
assertEquals("leavesayhello", processDefinition.getKey());
// 啟動流程並返回流程實例
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService
.startProcessInstanceByKey("leavesayhello");
assertNotNull(processInstance);
System.out.println("pid=" + processInstance.getId() + ", pdid="
+ processInstance.getProcessDefinitionId());
}
示例9: main
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx =
new AnnotationConfigApplicationContext();
ctx.register(SpringAnnotationConfiguration.class);
ctx.refresh();
assertNotNull(ctx.getBean(ProcessEngine.class));
assertNotNull(ctx.getBean(RuntimeService.class));
TaskService bean = ctx.getBean(TaskService.class);
assertNotNull(bean);
assertNotNull(ctx.getBean(HistoryService.class));
assertNotNull(ctx.getBean(RepositoryService.class));
assertNotNull(ctx.getBean(ManagementService.class));
assertNotNull(ctx.getBean(FormService.class));
Task task = bean.newTask();
task.setName("哈哈");
bean.saveTask(task);
}
示例10: testSpringMaster
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
@Test
public void testSpringMaster() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("mule/spring-master/spring-master.xml");
MuleContext mc = (MuleContext) ctx.getBean("_muleContext");
mc.start();
RepositoryService repositoryService = (RepositoryService) ctx.getBean("repositoryService");
repositoryService.createDeployment().addClasspathResource("mule/leaveWithMule.bpmn").deploy();
RuntimeService runtimeService = (RuntimeService) ctx.getBean("runtimeService");
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("days", 5);
runtimeService.startProcessInstanceByKey("leaveWithMule", variableMap);
TaskService taskService = (TaskService) ctx.getBean("taskService");
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertEquals("部門經理審批", task.getName());
mc.stop();
}
示例11: main
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
public static void main(String[] args) {
// 創建流程引擎
ProcessEngine engine = ProcessEngines
.getDefaultProcessEngine();
// 得到流程存儲服務組件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到運行時服務組件
RuntimeService runtimeService = engine.getRuntimeService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("com/roger/activiti/workflow/CompensationBoundaryEvent.bpmn").deploy();
// 初始化參數
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("result", false);
runtimeService.startProcessInstanceByKey("cbProcess", vars);
}
開發者ID:yudar1024,項目名稱:spring4-springmvc4-mybatis3-activiti,代碼行數:17,代碼來源:CompensationBoundaryEvent.java
示例12: main
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
public static void main(String[] args) {
// 創建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 得到流程存儲服務組件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到運行時服務組件
RuntimeService runtimeService = engine.getRuntimeService();
// 得到任務服務組件
TaskService taskService = engine.getTaskService();
// 得到管理服務組件
ManagementService managementService = engine.getManagementService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/SignalThrowingEvent.bpmn").deploy();
// 啟動流程
runtimeService.startProcessInstanceByKey("stProcess");
// 完成選擇商品任務
Task firstTask = taskService.createTaskQuery().singleResult();
taskService.complete(firstTask.getId());
// 完成用戶支付任務
Task payTask = taskService.createTaskQuery().singleResult();
taskService.complete(payTask.getId());
// 由於使用了異步的中間Throwing事件,因此會產生2條工作數據
List<Job> jobs = managementService.createJobQuery().list();
System.out.println(jobs.size());
}
示例13: main
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
// 創建流程引擎
ProcessEngineImpl engine = (ProcessEngineImpl)ProcessEngines
.getDefaultProcessEngine();
// 啟動JobExecutor
engine.getProcessEngineConfiguration().getJobExecutor().start();
// 得到流程存儲服務組件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到運行時服務組件
RuntimeService runtimeService = engine.getRuntimeService();
TaskService taskService = engine.getTaskService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/TimerCatchingEvent.bpmn").deploy();
// 啟動流程
runtimeService.startProcessInstanceByKey("tcProcess");
// 查詢當前任務
Task currentTask = taskService.createTaskQuery().singleResult();
taskService.complete(currentTask.getId());
Thread.sleep(1000 * 61);
// 重新查詢當前任務
currentTask = taskService.createTaskQuery().singleResult();
System.out.println("定時器中間事件的觸發後任務:" + currentTask.getName());
//關閉JobExecutor
engine.getProcessEngineConfiguration().getJobExecutor().shutdown();
}
示例14: main
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
public static void main(String[] args) {
// 創建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 得到流程存儲服務組件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到運行時服務組件
RuntimeService runtimeService = engine.getRuntimeService();
TaskService taskService = engine.getTaskService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/MessageCatchingEvent.bpmn").deploy();
// 啟動流程
ProcessInstance pi = runtimeService.startProcessInstanceByKey("mcProcess");
Execution exe = runtimeService.createExecutionQuery().activityId("messageintermediatecatchevent1").singleResult();
runtimeService.messageEventReceived("myMsg", exe.getId());
// 輸出當前的任務
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
System.out.println(task.getName());
}
}
示例15: main
import org.activiti.engine.RuntimeService; //導入依賴的package包/類
public static void main(String[] args) {
// 創建流程引擎
ProcessEngine engine = ProcessEngines
.getDefaultProcessEngine();
// 得到流程存儲服務組件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到運行時服務組件
RuntimeService runtimeService = engine.getRuntimeService();
// 獲取流程任務組件
TaskService taskService = engine.getTaskService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/ErrorBoundaryEvent.bpmn").deploy();
// 啟動流程
runtimeService.startProcessInstanceByKey("ebProcess");
// 進行任務查詢
Task task = taskService.createTaskQuery().singleResult();
System.out.println(task.getName());
}