ssh与jbpm4.3的调整
ssh与jbpm4.3的整合
首先说一下环境,spring3.0+struts2+hibernate3.4.0+jbpm4.3
jbpm的配置文件:logging.properties,jbpm.mail.properties,jbpm.mail.templates.examples.xml这三个配置文件就先不说了。主要是jbpm.cfg.xml和jbpm.hibernate.cfg.xml。
jbpm.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<!-- <import resource="jbpm.tx.hibernate.cfg.xml" />-->
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.tx.spring.cfg.xml" />
<!-- Job executor is excluded for running the example test cases. -->
<!-- To enable timers and messages in production use, this should be included. -->
<!--
<import resource="jbpm.jobexecutor.cfg.xml" />
-->
<import resource="jbpm.mail.templates.examples.xml" />
<process-engine-context>
<!-- <string name="spring.cfg" value="applicationContext-jbpm.xml" />-->
<command-service name="txRequiredCommandService">
<retry-interceptor />
<environment-interceptor />
<spring-transaction-interceptor current="true" />
</command-service>
<command-service name="newTxRequiredCommandService">
<retry-interceptor />
<environment-interceptor />
<spring-transaction-interceptor current="true" />
</command-service>
</process-engine-context>
<transaction-context>
<hibernate-session factory="sessionFactory" current="true" />
</transaction-context>
</jbpm-configuration>
jbpm.hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- <property name="current_session_context_class">thread</property>-->
<!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
<property name="hibernate.hbm2ddl.auto">create-drop</property><!--update也可以-->
<mapping resource="jbpm.repository.hbm.xml" />
<mapping resource="jbpm.execution.hbm.xml" />
<mapping resource="jbpm.history.hbm.xml" />
<mapping resource="jbpm.task.hbm.xml" />
<mapping resource="jbpm.identity.hbm.xml" />
</session-factory>
</hibernate-configuration>
spring的配置文件:
applicationContext-jbpm.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
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-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<bean id="processEngineWireContext" factory-bean="processEngine" factory-method="getProcessEngineWireContext" />
<!--这样写是因为jbpm4.3有一个循环引用的bug-->
<bean id="repositoryService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.RepositoryService</value>
</constructor-arg>
</bean>
<bean id="executionService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.ExecutionService</value>
</constructor-arg>
</bean>
<bean id="managementService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.ManagementService</value>
</constructor-arg>
</bean>
<bean id="taskService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.TaskService</value>
</constructor-arg>
</bean>
<bean id="historyService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.HistoryService</value>
</constructor-arg>
</bean>
<bean id="identityService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.IdentityService</value>
</constructor-arg>
</bean>
</beans>
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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- ========================= GENERAL DEFINITIONS ========================= -->
<!-- Configurer that replaces ${...} placeholders with values from properties files -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:conf/jdbc.properties</value>
<value>classpath:conf/hibernate/hibernate.properties</value>
</list>
</property>
</bean>
<context:component-scan base-package="com.asiasoft.ecrm"/>
<!-- Local Apache Commons DBCP DataSource that refers to a combined database -->
<!-- The placeholders are resolved from jdbc.properties through the PropertyPlaceholderConfigurer in applicationContext.xml -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.asiasoft.ecrm.corebiz.entity.*" />
<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.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
</props>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="transactionManager" />
</bean>
<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
<!--
Activates various annotations to be detected in bean classes: Spring's
@Required and @Autowired, as well as JSR 250's @PostConstruct,
@PreDestroy and @Resource (if available) and JPA's @PersistenceContext
and @PersistenceUnit (if available).
The implicitly registered post-processors include:
1. AutowiredAnnotationBeanPostProcessor,
2. CommonAnnotationBeanPostProcessor,
3. PersistenceAnnotationBeanPostProcessor,
4. RequiredAnnotationBeanPostProcessor.
-->
<context:annotation-config />
<!--
Instruct Spring to retrieve and apply @AspectJ aspects which are defined
as beans in this context.
-->
<aop:aspectj-autoproxy />
<!-- ========================= Aspect Configuration ======================== -->
<aop:config>
<!--
This definition creates auto-proxy infrastructure based on the given pointcut,
expressed in AspectJ pointcut language. Here: applying the advice named
"txAdvice" to all methods defined in the com.asiasoft.ecrm.corebiz package
or any sub-package under that.
-->
<aop:advisor pointcut="within(com.asiasoft.ecrm.corebiz.service..*)" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
</beans>
这样就可整合成了!
首先说一下环境,spring3.0+struts2+hibernate3.4.0+jbpm4.3
jbpm的配置文件:logging.properties,jbpm.mail.properties,jbpm.mail.templates.examples.xml这三个配置文件就先不说了。主要是jbpm.cfg.xml和jbpm.hibernate.cfg.xml。
jbpm.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<!-- <import resource="jbpm.tx.hibernate.cfg.xml" />-->
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.tx.spring.cfg.xml" />
<!-- Job executor is excluded for running the example test cases. -->
<!-- To enable timers and messages in production use, this should be included. -->
<!--
<import resource="jbpm.jobexecutor.cfg.xml" />
-->
<import resource="jbpm.mail.templates.examples.xml" />
<process-engine-context>
<!-- <string name="spring.cfg" value="applicationContext-jbpm.xml" />-->
<command-service name="txRequiredCommandService">
<retry-interceptor />
<environment-interceptor />
<spring-transaction-interceptor current="true" />
</command-service>
<command-service name="newTxRequiredCommandService">
<retry-interceptor />
<environment-interceptor />
<spring-transaction-interceptor current="true" />
</command-service>
</process-engine-context>
<transaction-context>
<hibernate-session factory="sessionFactory" current="true" />
</transaction-context>
</jbpm-configuration>
jbpm.hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- <property name="current_session_context_class">thread</property>-->
<!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
<property name="hibernate.hbm2ddl.auto">create-drop</property><!--update也可以-->
<mapping resource="jbpm.repository.hbm.xml" />
<mapping resource="jbpm.execution.hbm.xml" />
<mapping resource="jbpm.history.hbm.xml" />
<mapping resource="jbpm.task.hbm.xml" />
<mapping resource="jbpm.identity.hbm.xml" />
</session-factory>
</hibernate-configuration>
spring的配置文件:
applicationContext-jbpm.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
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-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<bean id="processEngineWireContext" factory-bean="processEngine" factory-method="getProcessEngineWireContext" />
<!--这样写是因为jbpm4.3有一个循环引用的bug-->
<bean id="repositoryService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.RepositoryService</value>
</constructor-arg>
</bean>
<bean id="executionService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.ExecutionService</value>
</constructor-arg>
</bean>
<bean id="managementService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.ManagementService</value>
</constructor-arg>
</bean>
<bean id="taskService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.TaskService</value>
</constructor-arg>
</bean>
<bean id="historyService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.HistoryService</value>
</constructor-arg>
</bean>
<bean id="identityService" factory-bean="processEngineWireContext" factory-method="get">
<constructor-arg>
<value type="java.lang.Class">org.jbpm.api.IdentityService</value>
</constructor-arg>
</bean>
</beans>
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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- ========================= GENERAL DEFINITIONS ========================= -->
<!-- Configurer that replaces ${...} placeholders with values from properties files -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:conf/jdbc.properties</value>
<value>classpath:conf/hibernate/hibernate.properties</value>
</list>
</property>
</bean>
<context:component-scan base-package="com.asiasoft.ecrm"/>
<!-- Local Apache Commons DBCP DataSource that refers to a combined database -->
<!-- The placeholders are resolved from jdbc.properties through the PropertyPlaceholderConfigurer in applicationContext.xml -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.asiasoft.ecrm.corebiz.entity.*" />
<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.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
</props>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="transactionManager" />
</bean>
<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
<!--
Activates various annotations to be detected in bean classes: Spring's
@Required and @Autowired, as well as JSR 250's @PostConstruct,
@PreDestroy and @Resource (if available) and JPA's @PersistenceContext
and @PersistenceUnit (if available).
The implicitly registered post-processors include:
1. AutowiredAnnotationBeanPostProcessor,
2. CommonAnnotationBeanPostProcessor,
3. PersistenceAnnotationBeanPostProcessor,
4. RequiredAnnotationBeanPostProcessor.
-->
<context:annotation-config />
<!--
Instruct Spring to retrieve and apply @AspectJ aspects which are defined
as beans in this context.
-->
<aop:aspectj-autoproxy />
<!-- ========================= Aspect Configuration ======================== -->
<aop:config>
<!--
This definition creates auto-proxy infrastructure based on the given pointcut,
expressed in AspectJ pointcut language. Here: applying the advice named
"txAdvice" to all methods defined in the com.asiasoft.ecrm.corebiz package
or any sub-package under that.
-->
<aop:advisor pointcut="within(com.asiasoft.ecrm.corebiz.service..*)" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
</beans>
这样就可整合成了!
1 楼
lykm02
2011-01-06
jbpm.cfg.xml好像有一部分内容和tx.spring.cfg.xml 中重复了