ssh与jbpm4.3的整合

cgy 2010-05-28

首先说一下环境,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

<?xmlversion="1.0"encoding="UTF-8"?>

<jbpm-configuration>

<importresource="jbpm.default.cfg.xml"/>

<importresource="jbpm.businesscalendar.cfg.xml"/>

<!--<importresource="jbpm.tx.hibernate.cfg.xml"/>-->

<importresource="jbpm.jpdl.cfg.xml"/>

<importresource="jbpm.bpmn.cfg.xml"/>

<importresource="jbpm.identity.cfg.xml"/>

<importresource="jbpm.tx.spring.cfg.xml"/>

<!--Jobexecutorisexcludedforrunningtheexampletestcases.-->

<!--Toenabletimersandmessagesinproductionuse,thisshouldbeincluded.-->

<!--

<importresource="jbpm.jobexecutor.cfg.xml"/>

-->

<importresource="jbpm.mail.templates.examples.xml"/>

<process-engine-context>

<!--<stringname="spring.cfg"value="applicationContext-jbpm.xml"/>-->

<command-servicename="txRequiredCommandService">

<retry-interceptor/>

<environment-interceptor/>

<spring-transaction-interceptorcurrent="true"/>

</command-service>

<command-servicename="newTxRequiredCommandService">

<retry-interceptor/>

<environment-interceptor/>

<spring-transaction-interceptorcurrent="true"/>

</command-service>

</process-engine-context>

<transaction-context>

<hibernate-sessionfactory="sessionFactory"current="true"/>

</transaction-context>

</jbpm-configuration>

jbpm.hibernate.cfg.xml

<?xmlversion="1.0"encoding="utf-8"?>

<!DOCTYPEhibernate-configurationPUBLIC

"-//Hibernate/HibernateConfigurationDTD3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<!--<propertyname="current_session_context_class">thread</property>-->

<!--propertyname="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property-->

<propertyname="hibernate.hbm2ddl.auto">create-drop</property><!--update也可以-->

<mappingresource="jbpm.repository.hbm.xml"/>

<mappingresource="jbpm.execution.hbm.xml"/>

<mappingresource="jbpm.history.hbm.xml"/>

<mappingresource="jbpm.task.hbm.xml"/>

<mappingresource="jbpm.identity.hbm.xml"/>

</session-factory>

</hibernate-configuration>

spring的配置文件:

applicationContext-jbpm.xml

<?xmlversion="1.0"encoding="UTF-8"?>

<beansxmlns="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/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/jeehttp://www.springframework.org/schema/jee/spring-jee-3.0.xsd

http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<beanid="springHelper"class="org.jbpm.pvm.internal.processengine.SpringHelper"/>

<beanid="processEngine"factory-bean="springHelper"factory-method="createProcessEngine"/>

<beanid="processEngineWireContext"factory-bean="processEngine"factory-method="getProcessEngineWireContext"/>

<!--这样写是因为jbpm4.3有一个循环引用的bug-->

<beanid="repositoryService"factory-bean="processEngineWireContext"factory-method="get">

<constructor-arg>

<valuetype="java.lang.Class">org.jbpm.api.RepositoryService</value>

</constructor-arg>

</bean>

<beanid="executionService"factory-bean="processEngineWireContext"factory-method="get">

<constructor-arg>

<valuetype="java.lang.Class">org.jbpm.api.ExecutionService</value>

</constructor-arg>

</bean>

<beanid="managementService"factory-bean="processEngineWireContext"factory-method="get">

<constructor-arg>

<valuetype="java.lang.Class">org.jbpm.api.ManagementService</value>

</constructor-arg>

</bean>

<beanid="taskService"factory-bean="processEngineWireContext"factory-method="get">

<constructor-arg>

<valuetype="java.lang.Class">org.jbpm.api.TaskService</value>

</constructor-arg>

</bean>

<beanid="historyService"factory-bean="processEngineWireContext"factory-method="get">

<constructor-arg>

<valuetype="java.lang.Class">org.jbpm.api.HistoryService</value>

</constructor-arg>

</bean>

<beanid="identityService"factory-bean="processEngineWireContext"factory-method="get">

<constructor-arg>

<valuetype="java.lang.Class">org.jbpm.api.IdentityService</value>

</constructor-arg>

</bean>

</beans>

applicationContext.xml

<?xmlversion="1.0"encoding="UTF-8"?>

<beansxmlns="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/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/jeehttp://www.springframework.org/schema/jee/spring-jee-3.0.xsd

http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<!--=========================GENERALDEFINITIONS=========================-->

<!--Configurerthatreplaces${...}placeholderswithvaluesfrompropertiesfiles-->

<beanid="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<propertyname="locations">

<list>

<value>classpath:conf/jdbc.properties</value>

<value>classpath:conf/hibernate/hibernate.properties</value>

</list>

</property>

</bean>

<context:component-scanbase-package="com.asiasoft.ecrm"/>

<!--LocalApacheCommonsDBCPDataSourcethatreferstoacombineddatabase-->

<!--Theplaceholdersareresolvedfromjdbc.propertiesthroughthePropertyPlaceholderConfigurerinapplicationContext.xml-->

<beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close">

<propertyname="driverClassName"value="${jdbc.driverClassName}"/>

<propertyname="url"value="${jdbc.url}"/>

<propertyname="username"value="${jdbc.username}"/>

<propertyname="password"value="${jdbc.password}"/>

</bean>

<!--HibernateSessionFactory-->

<beanid="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

<propertyname="configLocation"value="classpath:jbpm.hibernate.cfg.xml"/>

<propertyname="dataSource"ref="dataSource"/>

<propertyname="packagesToScan"value="com.asiasoft.ecrm.corebiz.entity.*"/>

<propertyname="hibernateProperties">

<props>

<propkey="hibernate.dialect">${hibernate.dialect}</prop>

<propkey="hibernate.show_sql">${hibernate.show_sql}</prop>

<propkey="hibernate.format_sql">${hibernate.format_sql}</prop>

<propkey="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>

<propkey="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>

</props>

</property>

</bean>

<!--TransactionmanagerforasingleHibernateSessionFactory(alternativetoJTA)-->

<beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager">

<propertyname="sessionFactory"ref="sessionFactory"/>

<propertyname="dataSource"ref="dataSource"/>

</bean>

<beanid="transactionTemplate"class="org.springframework.transaction.support.TransactionTemplate">

<propertyname="transactionManager"ref="transactionManager"/>

</bean>

<!--=========================BUSINESSOBJECTDEFINITIONS=========================-->

<!--

Activatesvariousannotationstobedetectedinbeanclasses:Spring's

@Requiredand@Autowired,aswellasJSR250's@PostConstruct,

@PreDestroyand@Resource(ifavailable)andJPA's@PersistenceContext

and@PersistenceUnit(ifavailable).

Theimplicitlyregisteredpost-processorsinclude:

1.AutowiredAnnotationBeanPostProcessor,

2.CommonAnnotationBeanPostProcessor,

3.PersistenceAnnotationBeanPostProcessor,

4.RequiredAnnotationBeanPostProcessor.

-->

<context:annotation-config/>

<!--

InstructSpringtoretrieveandapply@AspectJaspectswhicharedefined

asbeansinthiscontext.

-->

<aop:aspectj-autoproxy/>

<!--=========================AspectConfiguration========================-->

<aop:config>

<!--

Thisdefinitioncreatesauto-proxyinfrastructurebasedonthegivenpointcut,

expressedinAspectJpointcutlanguage.Here:applyingtheadvicenamed

"txAdvice"toallmethodsdefinedinthecom.asiasoft.ecrm.corebizpackage

oranysub-packageunderthat.

-->

<aop:advisorpointcut="within(com.asiasoft.ecrm.corebiz.service..*)"advice-ref="txAdvice"/>

</aop:config>

<tx:adviceid="txAdvice"transaction-manager="transactionManager">

<tx:attributes>

<tx:methodname="*"/>

</tx:attributes>

</tx:advice>

</beans>

这样就可整合成了!

相关推荐