SSH+activity工作流程整合開發

來源:互聯網
上載者:User

一直沒有更新最近,把以前的資料整理下。
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的

//擷取流程引擎對象,通過流程引擎對象可以擷取其他幾個服務物件@Resourceprivate ProcessEngine processEngine;//擷取部署流程物件服務,通過repositoryService可以部署流程資訊,查詢流程資訊@Resourceprivate  RepositoryService repositoryService;//擷取流程運行時對象,可通過查詢正在執行中的流程資訊@Resourceprivate RuntimeService  runtimeService;//任務服務物件,可通過他查詢任務資訊@Resourceprivate TaskService taskService;//曆史服務物件,通過他查詢曆史流程資訊@Resourceprivate 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>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.