SSH+activity工作流集成开发「建议收藏」

SSH+activity工作流集成开发「建议收藏」一直没有更新最近,把以前的资料整理下。SSH的集成配置清查看上一篇struts-2.3.24+spring-framework-4.1.6.RELEASE+hibernate-release-4.3.10.Final集成开发导入activity工作流需要的jaractiviti-bpmn-converter-5.16.4.jaractiviti-bpmn-layout-5

大家好,又见面了,我是你们的朋友全栈君。

一直没有更新最近,把以前的资料整理下。
SSH的集成配置清查看上一篇

struts-2.3.24+spring-framework-4.1.6.RELEASE+hibernate-release-4.3.10.Final
集成开发

导入activity工作流需要的jar
activiti-bpmn-converter-5.16.4.jar
activiti-bpmn-layout-5.16.4.jar
activiti-bpmn-model-5.16.4.jar
activiti-camel-5.16.4.jar
activiti-cdi.jar
activiti-common-rest-5.16.4.jar
activiti-crystalball-5.16.4.jar
activiti-cxf-5.16.4.jar
activiti-diagram-rest-5.16.4.jar
activiti-engine-5.16.4.jar
activiti-explorer-5.16.4.jar
activiti-image-generator-5.16.4.jar
activiti-json-converter-5.16.4.jar
activiti-ldap-5.16.4.jar
activiti-modeler-5.16.4.jar
activiti-mule-5.16.4.jar
activiti-osgi-5.16.4.jar
activiti-process-validation-5.16.4.jar
activiti-simple-workflow-5.16.4.jar
activiti-rest-5.16.4.jar
activiti-spring-5.16.4.jar

添加配置文件:新建activiti.cfg.xml文件

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <!-- spring负责创建流程引擎的配置文件 -->
    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
        <!-- 数据源 -->
        <property name="dataSource" ref="dataSource" />
        <!-- 配置事务管理器,统一事务 -->
        <property name="transactionManager" ref="txManager" />
        <!-- 设置建表策略,如果没有表,自动创建表 -->
        <property name="databaseSchemaUpdate" value="true" />
    </bean>
    <!-- 创建流程引擎对象 -->
    <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
        <property name="processEngineConfiguration" ref="processEngineConfiguration" />
    </bean>

    <!-- 相当于下面的代码 RepositoryServicie repositoryService = processEngine.getRepositoryService(); RuntimeServicie repositoryService = processEngine.getRuntimeServicie(); TaskServicie taskServicie = processEngine.getTaskServicie(); HistoryServicie historyServicie = processEngine.getHistoryServicie(); -->
    <!-- 由流程引擎对象,提供的方法,创建项目中使用的Activiti工作流的Service -->
    <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
    <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
    <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
    <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
    <bean id="formService" factory-bean="processEngine" factory-method="getFormService" />
</beans>

到此配置完成使用的时候可使用注解注入activity的

//获取流程引擎对象,通过流程引擎对象可以获取其他几个服务对象
@Resource
private ProcessEngine processEngine;
//获取部署流程对象服务,通过repositoryService可以部署流程信息,查询流程信息
@Resource
private  RepositoryService repositoryService;
//获取流程运行时对象,可通过查询正在执行中的流程信息
@Resource
private RuntimeService  runtimeService;
//任务服务对象,可通过他查询任务信息
@Resource
private TaskService taskService;
//历史服务对象,通过他查询历史流程信息
@Resource
private HistoryService  historyService;

通过

<import resource="classpath:activiti.cfg.xml" />

导入到applicationContext.xml配置文件,交给spring管理。详细查看applicationContext.xml配置。

接下来是activity的基本使用。

如下配置applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!-- 1、自动扫描与装配bean -->
    <context:component-scan base-package="cn.ssha"></context:component-scan>
    <!-- 导入外部的配置文件 -->
    <context:property-placeholder location="classpath:jdbc.properties" />
    <!-- 配置数据源 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="jdbcUrl" value="${jdbcUrl}"></property>
        <property name="driverClass" value="${driverClass}"></property>
        <property name="user" value="${user}"></property>
        <property name="password" value="${password}"></property>
        <!-- 其他配置 -->
        <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
        <property name="initialPoolSize" value="3"></property>
        <!--连接池中保留的最小连接数。Default: 3 -->
        <property name="minPoolSize" value="3"></property>
        <!--连接池中保留的最大连接数。Default: 15 -->
        <property name="maxPoolSize" value="5"></property>
        <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
        <property name="acquireIncrement" value="3"></property>
        <!-- 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 -->
        <property name="maxStatements" value="8"></property>
        <!--maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 -->
        <property name="maxStatementsPerConnection" value="5"></property>
        <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
        <property name="maxIdleTime" value="1800"></property>
    </bean>
    <!-- 配置sessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <!-- 指定hibernate的配置路径 -->
        <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
        <property name="dataSource" ref="dataSource"></property>
        <!-- 配置c3p0数据库连接池 <property name="dataSource"> <bean class="com.mchange.v2.c3p0.ComboPooledDataSource"> 数据库连接信息 <property name="jdbcUrl" value="${jdbcUrl}"></property> <property name="driverClass" value="${driverClass}"></property> <property name="user" value="${user}"></property> <property name="password" value="${password}"></property> 其他配置 初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 <property name="initialPoolSize" value="3"></property> 连接池中保留的最小连接数。Default: 3 <property name="minPoolSize" value="3"></property> 连接池中保留的最大连接数。Default: 15 <property name="maxPoolSize" value="5"></property> 当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 <property name="acquireIncrement" value="3"></property> 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 <property name="maxStatements" value="8"></property> maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 <property name="maxStatementsPerConnection" value="5"></property> 最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 <property name="maxIdleTime" value="1800"></property> </bean> </property> -->
        <!-- <property name="mappingResources"> <list> <value>cn/ssha/oa/doman/Product.hbm.xml</value> <value>cn/ssha/oa/doman/Employee.hbm.xml</value> <value>cn/ssha/oa/doman/LeaveBill.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect hibernate.show_sql=true hibernate.hbm2ddl.auto=update hibernate.temp.use_jdbc_metadata_defaults=false </value> </property> -->
    </bean>
    <!-- 配置声名式事务管理(采用注解的方式) -->
    <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <tx:annotation-driven transaction-manager="txManager" />
    <!-- 配置基础的Dao,在其他的DAO中只需要继承即可 -->
    <bean id="baseDao" abstract="true">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <import resource="classpath:activiti.cfg.xml" />

</beans>
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/144877.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • navicat 15 for my sql 激活码[最新免费获取]

    (navicat 15 for my sql 激活码)好多小伙伴总是说激活码老是失效,太麻烦,关注/收藏全栈君太难教程,2021永久激活的方法等着你。https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~1STL5S9V8F-eyJsaWNlbnNlSWQiOi…

    2022年3月27日
    170
  • IDEA 快捷键大全

    IDEA 快捷键大全Ctrl+Shift+Enter,语句完成“!”,否定完成,输入表达式时按“!”键Ctrl+E,最近的文件Ctrl+Shift+E,最近更改的文件Shift+Click,可以关闭文件Ctrl+[OR],可以跑到大括号的开头与结尾Ctrl+F12,可以显示当前文件的结构Ctrl+F7,可以查询当前元素在当前文件中的引用,然后按F3可以选择Ctrl+N,可以快速打开类C…

    2022年5月14日
    50
  • 十大经典武侠小说[通俗易懂]

    孤枕侧畔,一灯如豆,看尽万千红尘旧事刀枪入梦,剑气漫天,重温多少江湖恩仇    一说起武侠小说,每个像我这么大的男性或是比我小一些的男性都会眉飞色舞的侃上半天,仿佛每个人都是此中高手,但是武侠小说浩如烟海,能称得上作家的也多如牛毛,故高手或是低手之分并不在于看得多少,而在于精的程度。我之所以谈起这些来就不由得总是有些洋洋自得,便是因为我觉得自己看武侠小说既精又多,称得上此中高手,所

    2022年4月17日
    125
  • Mac OS mysql 启动命令

    Mac OS mysql 启动命令在MacOSX启动和停止MySQL服务的命令  启动MySQL服务  sudo/usr/local/mysql/support-files/mysql.serverstart 停止MySQL服务  sudo/usr/local/mysql/support-files/mysql.server stop 重启MySQL服务  sudo…

    2022年5月21日
    44
  • Laravel技巧:使用load、with预加载 区别

    Laravel技巧:使用load、with预加载 区别

    2021年11月8日
    48
  • ostringstream的使用方法

    ostringstream的使用方法ostringstream的使用方法【本文来自】http://www.builder.com.cn/2003/0304/83250.shtmlhttp://www.cppblog.com/alanto

    2022年7月4日
    34

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号