SSH+Activiti 整合(Spring 3.1.1 + Struts 2.3.3 + BoneCP 0.7.1 + Hibernate 4.1.4 + Activiti 5.9)

最近项目要用到工作流,所以考察了一下现在的开源工作流引擎,最终考虑在原SSH框架上整合Activiti 工作流引擎。还是那句话请转载的人注明出处,不要做让人看不起的IT人


多的不说了,本版只提供配置文件,其它部分文件代码可能参考我写的新版SSH整合一文。


applicationContext-common.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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util" xmlns:tool="http://www.springframework.org/schema/tool" xmlns:context="http://www.springframework.org/schema/context" 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/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd" default-lazy-init="true"> <context:property-placeholder ignore-unresolvable="true" location="classpath*:/dataBaseInfo.properties" /> <!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" p:jndiName="java:comp/env/jdbc/MySSH" /> --> <!-- BoneCP --> <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" p:driverClass="${jdbc.driver}" p:jdbcUrl="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}" p:idleConnectionTestPeriodInMinutes="${bonecp.idleConnectionTestPeriodInMinutes}" p:idleMaxAgeInMinutes="${bonecp.idleMaxAgeInMinutes}" p:maxConnectionsPerPartition="${bonecp.maxConnectionsPerPartition}" p:minConnectionsPerPartition="${bonecp.minConnectionsPerPartition}" p:partitionCount="${bonecp.partitionCount}" p:acquireIncrement="${bonecp.acquireIncrement}" p:statementsCacheSize="${bonecp.statementsCacheSize}" p:disableConnectionTracking="${bonecp.disableConnectionTracking}" p:releaseHelperThreads="${bonecp.releaseHelperThreads}" destroy-method="close" /> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" p:dataSource-ref="dataSource"> <property name="mappingLocations"> <list> <value>classpath*:/com/ronglian/uec_cloud/**/bo/*.hbm.xml</value> <value>classpath*:/entity/xml/*.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.use_sql_comments">${hibernate.use_sql_comments}</prop> <prop key="hibernate.max_fetch_depth">${hibernate.max_fetch_depth}</prop> <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop> <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop> <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop> <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop> <prop key="net.sf.ehcache.configurationResourceName">${net.sf.ehcache.configurationResourceName}</prop> <prop key="hibernate.order_updates">${hibernate.order_updates}</prop> <prop key="hibernate.query.factory_class">${hibernate.query.factory_class}</prop> <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop> <prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop> <!-- <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> --> </props> </property> </bean> <aop:aspectj-autoproxy expose-proxy="true"/> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" /> <aop:config expose-proxy="true"> <aop:pointcut id="txPointcut" expression="execution(* com.ronglian.uec_cloud..service..*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="create*" propagation="REQUIRED" /> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> <tx:method name="remove*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="edit*" propagation="REQUIRED"/> <tx:method name="merge*" propagation="REQUIRED" /> <tx:method name="put*" propagation="REQUIRED" /> <tx:method name="sync*" propagation="REQUIRED"/> <tx:method name="finish*" propagation="REQUIRED"/> <tx:method name="get*" propagation="REQUIRED" read-only="true" /> <tx:method name="count*" propagation="REQUIRED" read-only="true" /> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="list*" propagation="REQUIRED" read-only="true" /> <tx:method name="query*" propagation="REQUIRED" read-only="true" /> <tx:method name="check*" propagation="REQUIRED" read-only="true" /> <tx:method name="verify*" propagation="REQUIRED" read-only="true" /> <tx:method name="search*" propagation="REQUIRED" read-only="true" /> <tx:method name="select*" propagation="REQUIRED" read-only="true" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"> <property name="dataSource" ref="dataSource" /> <property name="transactionManager" ref="transactionManager" /> <property name="databaseSchemaUpdate" value="true" /> <property name="jobExecutorActivate" value="false" /> <property name="history" value="full" /> <property name="beans"> <map> <entry key="ITResReqsProcess_CurrentDepartmentApproval" value="DevDepartment"/> <entry key="ITResReqsProcess_ITDepartmentApprova" value="ITDepartment"/> <entry key="ITResReqsProcess_OperationMaintenanceDepartmentApproval" value="OperationMaintenanceDepartment"/> </map> </property> </bean> <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" > <property name="processEngineConfiguration" ref="processEngineConfiguration" /> </bean> <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" /> <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" /> <bean id="formService" factory-bean="processEngine" factory-method="getFormService" /> <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" /> <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" /> <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" /> <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" /> </beans>
applicationContext-commonBeans.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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util" xmlns:tool="http://www.springframework.org/schema/tool" xmlns:context="http://www.springframework.org/schema/context" 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/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd" default-lazy-init="true" default-autowire="byName" > <!-- 数据库操作Bean --> <bean id="dao" class="dao.DaoImpl" scope="singleton"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!--Service 原始Bean --> <bean id="baseService" class="service.BaseServiceImpl" scope="singleton" > <property name="dao" ref="dao" /> <property name="processEngine" ref="processEngine" /> <property name="repositoryService" ref="repositoryService" /> <property name="runtimeService" ref="runtimeService" /> <property name="formService" ref="formService" /> <property name="identityService" ref="identityService" /> <property name="taskService" ref="taskService" /> <property name="historyService" ref="historyService" /> <property name="managementService" ref="managementService" /> </bean> <!--Action 原始Bean --> <bean id="baseAction" class="action.BaseAction" scope="prototype" /> </beans>
applicationContext-beans.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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util" xmlns:tool="http://www.springframework.org/schema/tool" xmlns:context="http://www.springframework.org/schema/context" 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/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd" default-lazy-init="true" default-autowire="byName" > <!-- Member Login By Eric Shi --> <bean id="memberLoginService" class="com.ronglian.uec_cloud.member.service.impl.MemberLoginServiceImpl" scope="singleton" /> <bean id="memberLoginAction" class="com.ronglian.uec_cloud.member.action.MemberLoginAction" scope="prototype" /> <bean id="workflowManagementService" class="com.ronglian.uec_cloud.workflow.service.impl.WorkflowManagementServiceImpl" scope="singleton" /> <bean id="workflowManagementAction" class="com.ronglian.uec_cloud.workflow.action.WorkflowManagementAction" scope="prototype" /> </beans>
struts.xml

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <include file="struts-default.xml" /> <!-- 默认的配置包 --> <!-- <package name="defaultPackage" extends="struts-default,json-default,jfreechart-default,spring-default,ssl-default,tiles-default"> --> <package name="defaultPackage" extends="struts-default,json-default,jfreechart-default,spring-default"> <!-- <interceptors> --> <!-- <interceptor name="sessionOut" --> <!-- class="cn.newlinetech.iCenter.userCenter.interceptor.SessionProcessInterceptor" /> --> <!-- <interceptor-stack name="defaultInterceptor"> --> <!-- <interceptor-ref name="defaultStack" /> --> <!-- <interceptor-ref name="sessionOut" /> --> <!-- </interceptor-stack> --> <!-- </interceptors> --> <!-- <default-interceptor-ref name="defaultInterceptor" /> --> <global-results> <!-- 公用返回页面 --> <result name="error" type="dispatcher">/errorPage/index.jsp</result> <result name="login" type="dispatcher">/login.jsp</result> <result name="defaultLogin" type="redirect">/quitSys.jsp</result> <result name="loginOut" type="redirect">/loginAction!loginPage.action </result> <result name="ajaxJson" type="json"> <param name="contentType">text/html</param> <param name="root">ajax_json</param> </result> <!-- 异常返回页面 --> <result name="actionException" type="dispatcher">/WEB-INF/errorPage/ServiceException.jsp </result> <result name="serviceException" type="dispatcher">/WEB-INF/errorPage/ServiceException.jsp </result> <result name="daoException" type="dispatcher">/WEB-INF/errorPage/ServiceException.jsp </result> <result name="exception" type="dispatcher">/WEB-INF/errorPage/ServiceException.jsp </result> </global-results> <!-- 异常处理 --> <global-exception-mappings> <!-- Action 层异常处理 --> <exception-mapping result="actionException" exception="system.exception.ActionException" /> <!-- Service 层异常处理 --> <exception-mapping result="serviceException" exception="system.exception.ServiceException" /> <!-- DAO 层异常处理 --> <exception-mapping result="daoException" exception="system.exception.DaoException" /> <!-- 未知的系统异常,后台没有对此信息进行归类 --> <exception-mapping result="exception" exception="java.lang.Exception" /> </global-exception-mappings> </package> <!--前台调用静态方法--> <constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant> <!-- Member Login By Eric Shi --> <include file="/struts-config/member/member_Struts.xml" /> <include file="/struts-config/workflow/workflow_Struts.xml" /> </struts>
ehcache-hibernate.xml

<?xml version="1.0" encoding="UTF-8"?> <ehcache> <diskStore path="java.io.tmpdir/hibernate/chcache" /> <defaultCache maxElementsInMemory="10000" memoryStoreEvictionPolicy="LRU" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="300" overflowToDisk="false" diskPersistent="false" /> </ehcache>
member_Struts.xml

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="memberPackage" extends="defaultPackage"> <action name="login" class="memberLoginAction" method="memberUserLogin" /> <action name="welcome" class="memberLoginAction" method="gotoMainPage" > <result name="gotoMainPage" type="dispatcher">/WEB-INF/page/main.jsp</result> </action> </package> </struts>
dataBaseInfo.properties

#MySQL配置 hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect #hibernate.dialect=org.hibernate.dialect.MySQL5Dialect #hibernate.dialect=org.hibernate.dialect.MySQLDialect jdbc.url=jdbc:mysql://192.168.56.1:3306/sshDemo?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull jdbc.driver=com.mysql.jdbc.Driver jdbc.username=root jdbc.password=123456 hibernate.show_sql=true hibernate.format_sql=true hibernate.use_sql_comments=true #EhCache hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=false hibernate.cache.provider_class=net.sf.ehcache.hibernate.EhCacheProvider hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory net.sf.ehcache.configurationResourceName=ehcache/ehcache-hibernate.xml hibernate.hbm2ddl.auto=update #hibernate.hbm2ddl.auto=create-drop hibernate.order_updates=true hibernate.jdbc.batch_size=30 hibernate.jdbc.fetch_size=100 hibernate.max_fetch_depth=2 #hibernate4.0事务的模式 #1:org.hibernate.context.internal.ThreadLocalSessionContext - 当前session通过当前执行的线程来跟踪和界定。 #2:org.hibernate.context.internal.JTASessionContext - 当前session根据JTA来跟踪和界定。这和以前的仅支持JTA的方法是完全一样的。 #3:org.hibernate.context.internal.ManagedSessionContext #4:org.springframework.orm.hibernate4.SpringSessionContext - spring的事务管理。 hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext #Hibernate4.0的查询翻译器: hibernate.query.factory_class=org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory #Hibernate3.0的查询翻译器: #hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory #Hibernate2.1的查询翻译器 #hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory #Connection Pooling #acquireIncrement: 当连接池中的连接耗尽的时候一次同时获取的连接数。Default: 3 #idleConnectionTestPeriod:检查数据库连接池中控线连接的间隔时间,单位是分,默认值:240,如果要取消则设置为0 #idleMaxAge:连接池中未使用的链接最大存活时间,单位是分,默认值:60,如果要永远存活设置为0 #maxConnectionsPerPartition:每个分区最大的连接数 #minConnectionsPerPartition:每个分区最小的连接数 #partitionCount:分区数,默认值2,最小1,推荐3-4,视应用而定 #acquireIncrement:每次去拿数据库连接的时候一次性要拿几个,默认值:2 #statementsCacheSize:缓存prepared statements的大小,默认值:0 #releaseHelperThreads:每个分区释放链接助理进程的数量,默认值:3,除非你的一个数据库连接的时间内做了很多工作,不然过多的助理进程会影响你的性能 #BoneCP bonecp.minPoolSize=5 bonecp.maxPoolSize=20 bonecp.maxIdleTime=1800 bonecp.idleConnectionTestPeriodInMinutes=240 bonecp.maxStatements=0 bonecp.idleMaxAgeInMinutes=240 bonecp.maxConnectionsPerPartition=30 bonecp.minConnectionsPerPartition=5 bonecp.partitionCount=3 bonecp.acquireIncrement=5 bonecp.statementsCacheSize=50 bonecp.releaseHelperThreads=2 bonecp.disableConnectionTracking=true #activiti settings activiti.diagram.canvas.font=WenQuanYi Micro Hei
web.xml

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>UEC_Workflow</display-name> <distributable/> <session-config> <session-timeout>30</session-timeout> </session-config> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/spring-config/applicationContext-*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <listener> <listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class> </listener> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>struts-cleanup</filter-name> <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class> </filter> <filter-mapping> <filter-name>struts-cleanup</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>openSessionInViewFilter</filter-name> <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class> <init-param> <param-name>sessionFactoryBeanName</param-name> <param-value>sessionFactory</param-value> </init-param> <init-param> <param-name>singleSession</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>flushMode</param-name> <param-value>AUTO</param-value> </init-param> </filter> <filter-mapping> <filter-name>openSessionInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>ValidateCode</servlet-name> <servlet-class>util.ValidateCode.ValidateCodeServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ValidateCode</servlet-name> <url-pattern>/ValidateCode.png</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <location>/WEB-INF/errorPage/404.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/WEB-INF/errorPage/500.jsp</location> </error-page> </web-app>

Jar包:








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值