org.activiti.engine.RuntimeService Java Examples

The following examples show how to use org.activiti.engine.RuntimeService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivitiWithMuleTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #2
Source File: IntegrationAutoConfigurationTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testLaunchingGatewayProcessDefinition() throws Exception {
    AnnotationConfigApplicationContext applicationContext = this.context(InboundGatewayConfiguration.class);
    
    RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class);
    RuntimeService runtimeService = applicationContext.getBean(RuntimeService.class);
    ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);

    Assert.assertNotNull("the process engine should not be null", processEngine);
    Assert.assertNotNull("we should have a default repositoryService included", repositoryService);
    String integrationGatewayProcess = "integrationGatewayProcess";
    List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery()
            .processDefinitionKey(integrationGatewayProcess)
            .list();
    ProcessDefinition processDefinition = processDefinitionList.iterator().next();
    Assert.assertEquals(processDefinition.getKey(), integrationGatewayProcess);
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("customerId", 232);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(integrationGatewayProcess, vars);
    Assert.assertNotNull("the processInstance should not be null", processInstance);
    org.junit.Assert.assertTrue(
            applicationContext.getBean(InboundGatewayConfiguration.AnalysingService.class)
                    .getStringAtomicReference().get().equals(projectId));
}
 
Example #3
Source File: ProcessExecutionIntegrationTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void givenProcessDefinition_whenStartProcessInstance_thenProcessRunning() {
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment()
      .addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
      .deploy();

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("employeeName", "Kermit");
    variables.put("numberOfDays", new Integer(4));
    variables.put("vacationMotivation", "I'm really tired!");

    RuntimeService runtimeService = processEngine.getRuntimeService();
    ProcessInstance processInstance = runtimeService
      .startProcessInstanceByKey("vacationRequest", variables);

    Long count = runtimeService.createProcessInstanceQuery().count();
    assertTrue(count >= 1);
}
 
Example #4
Source File: AccessRequestService.java    From Gatekeeper with Apache License 2.0 6 votes vote down vote up
@Autowired
public AccessRequestService(TaskService taskService,
                            AccessRequestRepository accessRequestRepository,
                            GatekeeperRoleService gatekeeperRoleService,
                            RuntimeService runtimeService,
                            HistoryService historyService,
                            AccountInformationService accountInformationService,
                            SsmService ssmService,
                            GatekeeperApprovalProperties gatekeeperApprovalProperties){

    this.taskService = taskService;
    this.accessRequestRepository = accessRequestRepository;
    this.gatekeeperRoleService = gatekeeperRoleService;
    this.runtimeService = runtimeService;
    this.historyService = historyService;
    this.accountInformationService = accountInformationService;
    this.ssmService = ssmService;
    this.approvalPolicy = gatekeeperApprovalProperties;
}
 
Example #5
Source File: Application.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Bean
CommandLineRunner init(
        final AnalysingService analysingService,
        final RuntimeService runtimeService) {
    return new CommandLineRunner() {
        @Override
        public void run(String... strings) throws Exception {

            String integrationGatewayProcess = "integrationGatewayProcess";

            runtimeService.startProcessInstanceByKey(
                    integrationGatewayProcess, Collections.singletonMap("customerId", (Object) 232L));


            System.out.println("projectId=" + analysingService.getStringAtomicReference().get());

        }
    };
}
 
Example #6
Source File: VerySimpleLeaveProcessTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #7
Source File: MuleVMTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void send() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  RepositoryService repositoryService = processEngine.getRepositoryService();
  Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/mule/testVM.bpmn20.xml").deploy();

  RuntimeService runtimeService = processEngine.getRuntimeService();
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
  Assert.assertFalse(processInstance.isEnded());
  Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
  Assert.assertEquals(30, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");

  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  repositoryService.deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
Example #8
Source File: ApprovalTestApplication.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
public ApprovalTestApplication() {
    property(CrnkProperties.RESOURCE_DEFAULT_DOMAIN, "http://test.local");

    CrnkFeature feature = new CrnkFeature();
    initObjectMapper(feature);

    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    TaskService taskService = processEngine.getTaskService();
    ModuleRegistry moduleRegistry = feature.getBoot().getModuleRegistry();

    processEngine.getRepositoryService().createDeployment()
            .addClasspathResource("approval.bpmn20.xml")
            .deploy();

    ActivitiResourceMapper resourceMapper =
            new ActivitiResourceMapper(moduleRegistry.getTypeParser(), new DefaultDateTimeMapper());
    ApprovalMapper mapper = new ApprovalMapper();
    ApprovalManager approvalManager = new ApprovalManagerFactory().getInstance();
    approvalManager.init(runtimeService, taskService, resourceMapper, mapper, moduleRegistry);
    feature.addModule(createApprovalModule(approvalManager));
    feature.addModule(createActivitiModule(processEngine));
    feature.addModule(new TestModule());

    registerInstances(feature);
}
 
Example #9
Source File: MuleHttpBasicAuthTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void httpWithBasicAuth() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/mule/testHttpBasicAuth.bpmn20.xml").deploy();
  RuntimeService runtimeService = processEngine.getRuntimeService();
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
  Assert.assertFalse(processInstance.isEnded());
  Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
  Assert.assertEquals(10, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");
  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  processEngine.getRepositoryService().deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
Example #10
Source File: MuleHttpTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void http() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  Deployment deployment = processEngine.getRepositoryService().createDeployment()
      .addClasspathResource("org/activiti5/mule/testHttp.bpmn20.xml")
      .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
      .deploy();
  RuntimeService runtimeService = processEngine.getRuntimeService();
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
  Assert.assertFalse(processInstance.isEnded());
  Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
  Assert.assertEquals(20, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");
  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  processEngine.getRepositoryService().deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
Example #11
Source File: MuleHttpTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void http() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/mule/testHttp.bpmn20.xml").deploy();
  RuntimeService runtimeService = processEngine.getRuntimeService();
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
  Assert.assertFalse(processInstance.isEnded());
  Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
  Assert.assertEquals(20, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");
  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  processEngine.getRepositoryService().deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
Example #12
Source File: MuleVMTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void send() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  RepositoryService repositoryService = processEngine.getRepositoryService();
  Deployment deployment = repositoryService.createDeployment()
      .addClasspathResource("org/activiti5/mule/testVM.bpmn20.xml")
      .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
      .deploy();

  RuntimeService runtimeService = processEngine.getRuntimeService();
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
  Assert.assertFalse(processInstance.isEnded());
  Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
  Assert.assertEquals(30, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");

  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  repositoryService.deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
Example #13
Source File: CreateEngineUseSpringProxy.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Test
public void createEngineUseSpring() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-test.xml");
    ProcessEngineFactoryBean factoryBean = context.getBean(ProcessEngineFactoryBean.class);
    assertNotNull(factoryBean);

    RuntimeService bean = context.getBean(RuntimeService.class);
    assertNotNull(bean);
}
 
Example #14
Source File: ProcessTestExecutionListenerInTask.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Test
public void startProcess() throws Exception {
	RepositoryService repositoryService = activitiRule.getRepositoryService();
	repositoryService.createDeployment().addInputStream("executionListenerInTask.bpmn20.xml",
			new FileInputStream(filename)).deploy();
	RuntimeService runtimeService = activitiRule.getRuntimeService();
	Map<String, Object> variableMap = new HashMap<String, Object>();
	variableMap.put("name", "Activiti");
	ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("executionListenerInTask", variableMap);
	assertNotNull(processInstance.getId());
	System.out.println("id " + processInstance.getId() + " "
			+ processInstance.getProcessDefinitionId());
}
 
Example #15
Source File: AsyncFailingJobTestDataGenerator.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void generateTestData(ProcessEngine processEngine) {
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment().addClasspathResource("async-failing-expression.bpmn20.xml").deploy();

    RuntimeService runtimeService = processEngine.getRuntimeService();
    runtimeService.startProcessInstanceByKey("asyncFailingExpression");
}
 
Example #16
Source File: ParseHandlerTestDataGenerator.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void generateTestData(ProcessEngine processEngine) {
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment().addClasspathResource("parseHandlerProcess.bpmn20.xml").deploy();

    RuntimeService runtimeService = processEngine.getRuntimeService();
    runtimeService.startProcessInstanceByKey("parseHandlerTestProcess");
}
 
Example #17
Source File: StartProcessInstanceTestDataGenerator.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void generateTestData(ProcessEngine processEngine) {
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment().addClasspathResource("oneTaskProcess.bpmn20.xml").deploy();

    RuntimeService runtimeService = processEngine.getRuntimeService();
    runtimeService.startProcessInstanceByKey("oneTaskProcess", "activitiv5-one-task-process");
}
 
Example #18
Source File: ExpressionInJavaDelegateTestDataGenerator.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void generateTestData(ProcessEngine processEngine) {
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment().addClasspathResource("expressionInJavaDelegateProcess.bpmn20.xml").deploy();

    RuntimeService runtimeService = processEngine.getRuntimeService();
    runtimeService.startProcessInstanceByKey("expressionInJavaDelegate");
}
 
Example #19
Source File: CreateEngineUseSpringProxy.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Test
public void createEngineUseSpring() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-test.xml");
    ProcessEngineFactoryBean factoryBean = context.getBean(ProcessEngineFactoryBean.class);
    assertNotNull(factoryBean);

    RuntimeService bean = context.getBean(RuntimeService.class);
    assertNotNull(bean);
}
 
Example #20
Source File: CreateEngineUseSpringProxy.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Test
public void createEngineUseSpring() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-test.xml");
    ProcessEngineFactoryBean factoryBean = context.getBean(ProcessEngineFactoryBean.class);
    assertNotNull(factoryBean);

    RuntimeService bean = context.getBean(RuntimeService.class);
    assertNotNull(bean);
}
 
Example #21
Source File: ApprovalManager.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
public void init(RuntimeService runtimeService, TaskService taskService, ActivitiResourceMapper resourceMapper,
				 ApprovalMapper mapper,
				 ModuleRegistry moduleRegistry) {
	this.runtimeService = runtimeService;
	this.taskService = taskService;
	this.resourceMapper = resourceMapper;
	this.approvalMapper = mapper;
	this.moduleRegistry = moduleRegistry;
}
 
Example #22
Source File: JavaDelegateTestDataGenerator.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void generateTestData(ProcessEngine processEngine) {
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment().addClasspathResource("javaDelegateProcess.bpmn20.xml").deploy();

    RuntimeService runtimeService = processEngine.getRuntimeService();
    runtimeService.startProcessInstanceByKey("javaDelegateTestProcess");
}
 
Example #23
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 流程实例.
 */
public Page findProcessInstances(String tenantId, Page page) {
    RuntimeService runtimeService = processEngine.getRuntimeService();
    long count = runtimeService.createProcessInstanceQuery()
            .processInstanceTenantId(tenantId).count();
    List<ProcessInstance> processInstances = runtimeService
            .createProcessInstanceQuery().processInstanceTenantId(tenantId)
            .listPage((int) page.getStart(), page.getPageSize());
    page.setResult(processInstances);
    page.setTotalCount(count);

    return page;
}
 
Example #24
Source File: ActivitiSmokeTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ProcessInstance findProcessInstance(RuntimeService runtimeService, String instanceId)
{
    ProcessInstance instanceInDb = runtimeService.createProcessInstanceQuery()
    .processInstanceId(instanceId)
    .singleResult();
    return instanceInDb;
}
 
Example #25
Source File: SimulationRunContext.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public static RuntimeService getRuntimeService() {
  Stack<ProcessEngine> stack = getStack(processEngineThreadLocal);
  if (stack.isEmpty()) {
    return null;
  }
  return stack.peek().getRuntimeService();
}
 
Example #26
Source File: CreateEngineUseSpringProxy.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Test
public void createEngineUseSpring() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-test.xml");
    ProcessEngineFactoryBean factoryBean = context.getBean(ProcessEngineFactoryBean.class);
    assertNotNull(factoryBean);

    RuntimeService bean = context.getBean(RuntimeService.class);
    assertNotNull(bean);
}
 
Example #27
Source File: CreateEngineUseSpringProxy.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Test
public void createEngineUseSpring() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-test.xml");
    ProcessEngineFactoryBean factoryBean = context.getBean(ProcessEngineFactoryBean.class);
    assertNotNull(factoryBean);

    RuntimeService bean = context.getBean(RuntimeService.class);
    assertNotNull(bean);
}
 
Example #28
Source File: ActivitiRuleJunit4Test.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment
public void ruleUsageExample() {
  RuntimeService runtimeService = activitiRule.getRuntimeService();
  runtimeService.startProcessInstanceByKey("ruleUsage");
  
  TaskService taskService = activitiRule.getTaskService();
  Task task = taskService.createTaskQuery().singleResult();
  assertEquals("My Task", task.getName());
  
  taskService.complete(task.getId());
  assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
 
Example #29
Source File: ReplayRunTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessInstanceStartEvents() throws Exception {
  ProcessEngineImpl processEngine = initProcessEngine();

  TaskService taskService = processEngine.getTaskService();
  RuntimeService runtimeService = processEngine.getRuntimeService();

  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put(TEST_VARIABLE, TEST_VALUE);
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(USERTASK_PROCESS, BUSINESS_KEY, variables);

  Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
  TimeUnit.MILLISECONDS.sleep(50);
  taskService.complete(task.getId());

  final SimulationDebugger simRun = new ReplaySimulationRun(processEngine, getReplayHandlers(processInstance.getId()));

  simRun.init(new NoExecutionVariableScope());

  // original process is finished - there should not be any running process instance/task
  assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
  assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());

  simRun.step();

  // replay process was started
  assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
  // there should be one task
  assertEquals(1, taskService.createTaskQuery().taskDefinitionKey("userTask").count());

  simRun.step();

  // userTask was completed - replay process was finished
  assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
  assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());

  simRun.close();
  processEngine.close();
  ProcessEngines.destroy();
}
 
Example #30
Source File: App.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 5 votes vote down vote up
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("MyFirstProcess.bpmn").deploy();
	// process的id属性
	ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess");
	
	// 普通员工完成请假的任务
	Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
	System.out.println("当前流程节点:" + task.getName());
	taskService.complete(task.getId());
	
	// 经理审批任务
	task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
	System.out.println("当前流程节点:" + task.getName());
	taskService.complete(task.getId());
	
	// 流程结束
	task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
	System.out.println("流程结束:" + task);
	// 关闭流程引擎
	engine.close();
}