Java Code Examples for org.activiti.engine.ProcessEngine#close()

The following examples show how to use org.activiti.engine.ProcessEngine#close() . 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: SortGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

	IdentityService identityService = engine.getIdentityService();

	List<Group> groups = identityService.createGroupQuery()
			.orderByGroupName().desc().list();

	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---"
				+ group.getType());
	}

	// 关闭流程引擎
	engine.close();
}
 
Example 2
Source File: ListPageGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

	IdentityService identityService = engine.getIdentityService();

	List<Group> groups = identityService.createGroupQuery().listPage(1, 5);

	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---"
				+ group.getType());
	}

	// 关闭流程引擎
	engine.close();
}
 
Example 3
Source File: NativeQuery.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

	IdentityService identityService = engine.getIdentityService();

	List<Group> groups = identityService.createNativeGroupQuery()
			.sql("SELECT * FROM ACT_ID_GROUP WHERE NAME_ = #{name}")
			.parameter("name", "Group_3").list();

	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---"
				+ group.getType());
	}

	// 关闭流程引擎
	engine.close();
}
 
Example 4
Source File: FieldQuery.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

	IdentityService identityService = engine.getIdentityService();

	List<Group> groups = identityService.createGroupQuery()
			.groupName("Group_3").groupType("TYPE_0").list();

	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---"
				+ group.getType());
	}

	// 关闭流程引擎
	engine.close();
}
 
Example 5
Source File: SchemaErrorTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {           
// 新建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 存储服务
RepositoryService repositoryService = engine.getRepositoryService();
// 新建部署构造器
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
// 增加错误的schema文件(包括无效的标签)<test>test</test> 
// 校验报错:发现了以元素 'test' 开头的无效内容。
deploymentBuilder.addClasspathResource("error/schema_error.bpmn");
// 禁用Schema验证
deploymentBuilder.disableSchemaValidation();
// 发布部署构造器
deploymentBuilder.deploy();
// 关闭流程引擎
engine.close();
  }
 
Example 6
Source File: FieldQuery.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

	IdentityService identityService = engine.getIdentityService();

	List<Group> groups = identityService.createGroupQuery()
			.groupName("Group_3").groupType("TYPE_0").list();

	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---"
				+ group.getType());
	}

	// 关闭流程引擎
	engine.close();
}
 
Example 7
Source File: SchemaErrorTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {           
// 新建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 存储服务
RepositoryService repositoryService = engine.getRepositoryService();
// 新建部署构造器
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
// 增加错误的schema文件(包括无效的标签)<test>test</test> 
// 校验报错:发现了以元素 'test' 开头的无效内容。
deploymentBuilder.addClasspathResource("error/schema_error.bpmn");
// 禁用Schema验证
deploymentBuilder.disableSchemaValidation();
// 发布部署构造器
deploymentBuilder.deploy();
// 关闭流程引擎
engine.close();
  }
 
Example 8
Source File: BpmnErrorTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {       
// 新建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 存储服务
RepositoryService repositoryService = engine.getRepositoryService();
// 新建部署构造器
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
// 增加错误的schema文件(包括无效的标签)<test>test</test>
// 报错信息:[Validation set: 'activiti-executable-process' | 
//Problem: 'activiti-start-event-multiple-found'] : 
//Multiple none start events are not supported - 
//[Extra info : processDefinitionId = myProcess | 
// processDefinitionName = My process |  | id = startevent1 |  
//| activityName = Start | ] ( line: 4, column: 47)
deploymentBuilder.addClasspathResource("error/bpmn_error.bpmn");
// 禁用Bpmn验证
deploymentBuilder.disableBpmnValidation();
// 发布部署构造器
deploymentBuilder.deploy();
// 关闭流程引擎
engine.close();
  }
 
Example 9
Source File: TextQueryTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 存储服务
	RepositoryService repositoryService = engine.getRepositoryService();
	// 新建部署构造器
	DeploymentBuilder deploymentBuilder = repositoryService
			.createDeployment();
	deploymentBuilder.addClasspathResource("my_text.txt");
	Deployment deployment = deploymentBuilder.deploy();
	// 数据查询
	InputStream inputStream = repositoryService.getResourceAsStream(
			deployment.getId(), "my_text.txt");
	int count = inputStream.available();
	byte[] contents = new byte[count];
	inputStream.read(contents);
	String result = new String(contents);
	// 输入结果
	System.out.println(result);
	// 关闭流程引擎
	engine.close();
}
 
Example 10
Source File: SaveGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	
	IdentityService identityService = engine.getIdentityService();
	
	Random ran = new Random(10);
	for (int i = 0; i < 10; i++) {
		Group group = identityService.newGroup(String.valueOf(i));
		group.setName("Group_" + ran.nextInt(10));
		group.setType("TYPE_" + ran.nextInt(10));
		identityService.saveGroup(group);
	}

	// 关闭流程引擎
	engine.close();
}
 
Example 11
Source File: SchemaBootstrap.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Initialises the Activiti DB schema, if not present it's created.
 * 
 * @param connection Connection to use the initialise DB schema
 */
private void initialiseActivitiDBSchema(Connection connection)
{
    // create instance of activiti engine to initialise schema
    ProcessEngine engine = null;
    ProcessEngineConfiguration engineConfig = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
    try
    {
        // build the engine
        engine = engineConfig.setDataSource(dataSource).
            setDatabaseSchemaUpdate("none").
            setProcessEngineName("activitiBootstrapEngine").
            setHistory("full").
            setJobExecutorActivate(false).
            buildProcessEngine();

        String schemaName = dbSchemaName != null ? dbSchemaName : databaseMetaDataHelper.getSchema(connection);
        if (logger.isInfoEnabled())
        {
            logger.info("Creating Activiti DB schema tables");
        }
        engine.getManagementService().databaseSchemaUpgrade(connection, null, schemaName);
    }
    finally
    {
        if (engine != null)
        {
            // close the process engine
            engine.close();
        }
    }
}
 
Example 12
Source File: CountGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 5 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	
	IdentityService identityService = engine.getIdentityService();		
	// 
	Long count = identityService.createGroupQuery().count();
	
	System.out.println(count);		

	// 关闭流程引擎
	engine.close();
}
 
Example 13
Source File: ListGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 5 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	
	IdentityService identityService = engine.getIdentityService();
	
	List<Group> groups = identityService.createGroupQuery().list();
	
	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---" + group.getType());
	}		

	// 关闭流程引擎
	engine.close();
}
 
Example 14
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();
}
 
Example 15
Source File: SingleResult.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 5 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

	IdentityService identityService = engine.getIdentityService();
	//
	Group group = identityService.createGroupQuery().groupName("Group_5")
			.singleResult();

	System.out.println(group.getId() + "---" + group.getName() + "---"
			+ group.getType());

	// 关闭流程引擎
	engine.close();
}
 
Example 16
Source File: CountGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 5 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	
	IdentityService identityService = engine.getIdentityService();		
	// 
	Long count = identityService.createGroupQuery().count();
	
	System.out.println(count);		

	// 关闭流程引擎
	engine.close();
}
 
Example 17
Source File: ListGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 5 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	
	IdentityService identityService = engine.getIdentityService();
	
	List<Group> groups = identityService.createGroupQuery().list();
	
	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---" + group.getType());
	}		

	// 关闭流程引擎
	engine.close();
}
 
Example 18
Source File: ProcessDefinitionCacheTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void testDeployRevisedProcessAfterDeleteOnOtherProcessEngine() {
  
  // Setup both process engines
  StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration = new StandaloneProcessEngineConfiguration();
  standaloneProcessEngineConfiguration.setProcessEngineName("reboot-test-schema");
  standaloneProcessEngineConfiguration.setDatabaseSchemaUpdate(org.activiti5.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
  standaloneProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000");
  standaloneProcessEngineConfiguration.setAsyncExecutorActivate(false);
  standaloneProcessEngineConfiguration.setActiviti5CompatibilityEnabled(true);
  ProcessEngine processEngine1 = standaloneProcessEngineConfiguration.buildProcessEngine();
  RepositoryService repositoryService1 = processEngine1.getRepositoryService();
  
  StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration2 = new StandaloneProcessEngineConfiguration();
  standaloneProcessEngineConfiguration2.setProcessEngineName("reboot-test");
  standaloneProcessEngineConfiguration2.setDatabaseSchemaUpdate(org.activiti5.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE);
  standaloneProcessEngineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000");
  standaloneProcessEngineConfiguration2.setAsyncExecutorActivate(false);
  standaloneProcessEngineConfiguration2.setActiviti5CompatibilityEnabled(true);
  ProcessEngine processEngine2  = standaloneProcessEngineConfiguration2.buildProcessEngine();
  RepositoryService repositoryService2 = processEngine2.getRepositoryService();
  RuntimeService runtimeService2 = processEngine2.getRuntimeService();
  TaskService taskService2 = processEngine2.getTaskService();
  
  // Deploy first version of process: start->originalTask->end on first process engine
  String deploymentId = repositoryService1.createDeployment()
    .addClasspathResource("org/activiti5/engine/test/cache/originalProcess.bpmn20.xml")
    .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
    .deploy()
    .getId();
  
  // Start process instance on second engine
  String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
  runtimeService2.startProcessInstanceById(processDefinitionId);
  Task task = taskService2.createTaskQuery().singleResult();
  assertEquals("original task", task.getName());
  
  // Delete the deployment on second process engine
  repositoryService2.deleteDeployment(deploymentId, true);
  assertEquals(0, repositoryService2.createDeploymentQuery().count());
  assertEquals(0, runtimeService2.createProcessInstanceQuery().count());
  
  // deploy a revised version of the process: start->revisedTask->end on first process engine
  //
  // Before the bugfix, this would set the cache on the first process engine,
  // but the second process engine still has the original process definition in his cache.
  // Since there is a deployment delete in between, the new generated process definition id is the same 
  // as in the original deployment, making the second process engine using the old cached process definition.
  deploymentId = repositoryService1.createDeployment()
    .addClasspathResource("org/activiti5/engine/test/cache/revisedProcess.bpmn20.xml")
    .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
    .deploy()
    .getId();
  
  // Start process instance on second process engine -> must use revised process definition
  repositoryService2.createProcessDefinitionQuery().singleResult().getId();
  runtimeService2.startProcessInstanceByKey("oneTaskProcess");
  task = taskService2.createTaskQuery().singleResult();
  assertEquals("revised task", task.getName());
  
  // cleanup
  repositoryService1.deleteDeployment(deploymentId, true);
  processEngine1.close();
  processEngine2.close();
}
 
Example 19
Source File: TestHelper.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public static void closeProcessEngines() {
  for (ProcessEngine processEngine : processEngines.values()) {
    processEngine.close();
  }
  processEngines.clear();
}
 
Example 20
Source File: AsyncExecutorTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
private void cleanup(ProcessEngine processEngine) {
	for (org.activiti.engine.repository.Deployment deployment : processEngine.getRepositoryService().createDeploymentQuery().list()) {
		processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true);
	}
	processEngine.close();
}