Activiti获取ProcessEngine的三种方法
1.通过ProcessEngineConfiguration获取
package cn.lonecloud.mavenActivi; import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;
/**
* 通过使用ProcessEngineConfiguration获取
* @Title: ConfigByClass.java
* @Package cn.lonecloud.mavenActivi
* @Description:
* @author lonecloud
* @date 2016年8月22日 下午10:50:33
*/
public class ConfigByClass {
@Test
public void config() {
//获取config对象
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration();
//Jdbc设置
String jdbcDriver = "com.mysql.jdbc.Driver";
processEngineConfiguration.setJdbcDriver(jdbcDriver);
String jdbcUrl = "jdbc:mysql://localhost:3306/mavenActiviti?useUnicode=true&characterEncoding=utf-8";
processEngineConfiguration.setJdbcUrl(jdbcUrl);
String jdbcUsername = "root";
processEngineConfiguration.setJdbcUsername(jdbcUsername);
String jdbcPassword = "123456";
processEngineConfiguration.setJdbcPassword(jdbcPassword);
/**
* Checks the version of the DB schema against the library when the
* process engine is being created and throws an exception if the
* versions don't match.
*/
// public static final String DB_SCHEMA_UPDATE_FALSE = "false";//不自动创建新表 /**
* Creates the schema when the process engine is being created and drops
* the schema when the process engine is being closed.
*/
// public static final String DB_SCHEMA_UPDATE_CREATE_DROP = "create-drop";//每次运行创建新表 /**
* Upon building of the process engine, a check is performed and an
* update of the schema is performed if it is necessary.
*/
// public static final String DB_SCHEMA_UPDATE_TRUE = "true";设置自动对表结构进行改进和升级
//设置是否自动更新
processEngineConfiguration
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
//获取引擎对象
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
processEngine.close();
}
}
2.通过ProcessEngineConfiguration载入xml文件
xml文件:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!--这里的类太多别导错了 -->
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- 配置流程引擎配置对象 -->
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti?useUnicode=true&characterEncoding=utf-8"></property>
<property name="jdbcUsername" value="root"></property>
<property name="jdbcPassword" value="123456"></property>
<!-- 注入数据源信息 -->
<property name="databaseSchemaUpdate" value="true"></property>
</bean> <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<!-- 注入自动建表设置 -->
<property name="processEngineConfiguration" ref="processEngineConfiguration"></property>
</bean>
</beans>
java
package cn.lonecloud.mavenActivi; import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.ProcessEngines;
import org.junit.Test;
/**
* 通过通过配置文件进行初始化获取引擎对
* @Title: ConfigByConfig.java
* @Package cn.lonecloud.mavenActivi
* @Description:
* @author lonecloud
* @date 2016年8月22日 下午10:40:35
*/
public class ConfigByConfig {
/**
* 通过配置文件进行初始化获取引擎对象
* @Description:
*/
@Test
public void configByConf(){
//载入资源
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
//创建引擎
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
processEngine.getRepositoryService();
}
}
3.通过默认载入activiti.cfg.xml进行获取
* 通过默认载入activiti.cfg.xml进行获取
* @Description:推荐使用
*/
@Test
public void configByDefault(){
//通过获取载入默认获取
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
processEngine.close();
}
这里的xml文件名必须设置为activiti.cfg.xml
Activiti获取ProcessEngine的三种方法的更多相关文章
- 体温数据上传程序开发+获取时间的三种方法+DB Browser下载及安装
今天开始了体温上传程序的开发 今日所学: 获取时间 (21条消息) (转)安卓获取时间的三种方法_sharpeha的博客-CSDN博客_安卓获取时间 DB Browser安装教程 (20条消息) sq ...
- java 获取随机数的三种方法
方法1(数据类型)(最小值+Math.random()*(最大值-最小值+1))例:(int)(1+Math.random()*(10-1+1))从1到10的int型随数 方法2获得随机数for (i ...
- URL转Drawable之 Android中获取网络图片的三种方法
转载自: http://doinone.iteye.com/blog/1074283 Android中获取网络图片是一件耗时的操作,如果直接获取有可能会出现应用程序无响应(ANR:Applicatio ...
- android系统通过图片绝对路径获取URI的三种方法
最近做项目要通过图片的绝对路径找到图片的URI,然后删除图片,小小总结一下获取URI的方法,亲自试验在 android 4.1.3的系统上都是可用的. 1.将所有的图片路径取出,遍历比较找到需要的路径 ...
- js jquery 获取服务器控件的三种方法
由于ASP.NET网页运行后,服务器控件会随机生成客户端id,jquery获取时候不太好操作,google了下,总结有以下3种方法: 服务器控件代码:<asp:TextBox ID=" ...
- 获取IP的三种方法
第一种 取本主机ip地址 public string GetLocalIp() { ///获取本地的IP地址 string AddressIP = string.Empty; foreach (IPA ...
- node获取当前路径的三种方法
node提供了3种获取路径的方法 ,在当前目录下,运行node const {resolve} = require('path') console.log('__dirname : ' + __di ...
- java获取文件名的三种方法
import java.io.File; import java.util.Arrays; public class FileName { /** * @param args */ public st ...
- js获取时间戳的三种方法
1.Date.Now() 2.new Date().getTime() 3.Date.parse(new Date()) 其中1和2是相同含义 chrome控制台键入:Date.now() ===ne ...
随机推荐
- Java this 关键字的用法
this 关键字的用法 this 在类中就是代表当前对象,可以通过 this 关键字完成当前 对象的成员属性.成员方法和构造方法的调用. 那么何时用 this? 当在定义类中的方法时,如果需要调用该类 ...
- 通过EXPLAIN分析低效SQL的执行计划
explain select * from film where rating>9\G; select_type 表示select的类型 SIMPLE 代表简单表,不用表连接或子查询 PRIMR ...
- linux_初始参数选择
目前linux发行版? linux内核 : Linux Kernel2.2 2.4 2.6 3.x 发行版本: Red Hat 主流 6.x, 正在发展 7.x Fedora: 为Red Hat ...
- scrapy_cookie禁用_延迟下载_自定义爬虫setting
如何设置禁止cookie? 在setting中 添加字段: COOKIE_ENABLED = False # False关闭cookie,True ...
- junit源码解析总结
前面的博客我们也已经整理到了,我们使用junit38,在写测试类的时候我们的测试类必须继承TestCase.这个所有测试类的父类在junit.framework包下面. 前面我们的整理都是说直接在ID ...
- DOM4J使用简介
Dom4j 使用简介 作者:冰云 icecloud(AT)sina.com 时间:2003.12.15 版权声明: 本文由冰云完成,首发于CSDN,未经许可,不得使用于任何商业用途. 文中代码部分 ...
- java URL和URLConnection
*/ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...
- php之快速排序
<?phpfunction shell_sort(array $arr){ $right=$left = array(); $Rights=$Lefts = array() ...
- Codeforces C. Classroom Watch
C. Classroom Watch time limit per test 1 second memory limit per test 512 megabytes input standard i ...
- Sorting Slides(二分图匹配——确定唯一匹配边)
题目描述: Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not ...