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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 关于allow_url_fopen的设置与服务器的安全–不理解

    关于allow_url_fopen的设置与服务器的安全–不理解allow_url_fopen与安全以及PHPlibcurl  allow_url_fopen=ON常常会给服务器和管理员带来麻烦,但是经常性(至少我这样认为)的我们需要远程读取某个东西,如果设置allow_url_fopen=OFF将其关闭,我们就没有办法远程读取。  幸好我们有一个很好的PHP模块–curl。下面我就以一个例子说说我用curl远程读取的方法:  第一,a

    2022年7月21日
  • MySQL使用SQL语句修改表名

    MySQL使用SQL语句修改表名MySQL中可以使用renametable这个SQL语句来修改表名。renametable这个SQL语句来修改表名的基本语法是:RENAMETABLE<旧表名>TO<新表名>;我们来把test表修改为test1表。1、首先查看一下当前数据库中有哪些表。mysql>showtables;+——————-+…

    2022年5月6日
  • mybatis二级缓存实现_mybatis源码深度解析

    mybatis二级缓存实现_mybatis源码深度解析 二级缓存的作用域是全局,换句话说,二级缓存已经脱离SqlSession的控制了。在测试二级缓存之前,我先把结论说一下:二级缓存的作用域是全局的,二级缓存在SqlSession关闭或提交之后才会生效。在分析MyBatis的二级缓存之前,我们先简单看下MyBatis中一个关于二级缓存的类(其他相关的类和接口之前已经分析过):org.apache.ibatis.mapping.Ma…

    2022年9月2日
  • Java.Utils:网络工具包[通俗易懂]

    Java.Utils:网络工具包[通俗易懂]packagecom.boob.common.utils;importorg.springframework.util.MultiValueMap;importorg.springframework.web.util.UriComponentsBuilder;importjavax.net.ssl.HttpsURLConnection;importjavax.servlet….

    2022年7月16日
  • matlab randint,Matlab的randint函数用法「建议收藏」

    RANDINTGeneratematrixofuniformlydistributedrandomintegers.OUT=RANDINTgeneratesa”0″or”1″withequalprobability.OUT=RANDINT(M)generatesanM-by-Mmatrixofrandombinarynumbers.”0″an…

    2022年4月10日
  • 批量下载ts视频文件

    批量下载ts视频文件第一步使用chrome按F12进入开发模式,拖动视频进度条到视频结束;然后找到.m3u8以结尾的文件并保存为文本文件。第二步点开查看里面是否存在如下以ts结尾的文件内容……/20180802/eXLFMdky/800kb/hls/QV7N1B14122999.ts/20180802/eXLFMdky/800kb/hls/QV7N1B14123000.ts…

    2022年7月18日

发表回复

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

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