ssh与jbpm4.4的整合

建Web 工程。导入java包  其中包括ssh所依赖的jar包  和jbpm.jar  和jbpm4.4/lib下的所有jar 包

其中与tomcat 6.0 有冲突 的解决办法网上有。这里就不多说了

在jbpm-4.4\install\src\db\create 文件夹中找到对应数据库的建表语句。然后去数据库执行.

1.编写spring 的配置文件 applicationContext_base.xml

建立sessionFactory  这里要要用到jbpm.hibernate.cfg.xml

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="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="hibernate.connection.url">jdbc:oracle:thin@localhost:1521:orcl</property>
    <property name="hibernate.connection.username">alex</property>
    <property name="hibernate.connection.password">vallen</property>
    <property name="hibernate.format_sql">true</property>

    <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>

applicationContext_base.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"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

	    <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper"  
        lazy-init="default" autowire="default" dependency-check="default">  
        <property name="jbpmCfg">  
            <value>jbpm.cfg.xml</value>  
        </property>  
    </bean> 
	 
	 <bean id="processEngine" factory-bean="springHelper"  
	 	factory-method="createProcessEngine" />  
	<bean id="sessionFactory" 
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="configLocation">
			<value>classpath:jbpm.hibernate.cfg.xml</value>
		</property>
	</bean>
	</beans>
 

2.spring 与 jbpm整合

在src下建一个 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.spring.cfg.xml" />
  <import resource="jbpm.jpdl.cfg.xml" />
  <import resource="jbpm.bpmn.cfg.xml" />
  <import resource="jbpm.identity.cfg.xml" />
  <import resource="jbpm.console.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" />
  -->
<!-- 这里说明一下,默认的路径是classpath  所以必须加上xml的路径 如果 直接 写成    value ="/WEB-INF/config/applicationContext_base.xml" 会从classpath目录开始找起 到最后会是找不到的。 所以。必须用相对路径-->
  <process-engine-context>
    <string name="spring.cfg" value="../../WEB-INF/config/applicationContext_base.xml" />
  </process-engine-context>	
  <import resource="jbpm.mail.templates.xml"></import>
</jbpm-configuration>
 

其中在src下还有两个关于mail的配置  jbpm.mail.templates.xml 和 jbpm.mail.properties

jbpm.mail.templates.xml 

<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration>

  <process-engine-context>

    <mail-template name='task-notification'>
      <to users="${task.assignee}"/>
      <subject>${task.name}</subject>
      <text><![CDATA[Hi ${task.assignee},
Task "${task.name}" has been assigned to you.
${task.description}

Sent by jBPM]]></text>
    </mail-template>

    <mail-template name='task-reminder'>
      <to users="${task.assignee}"/>
      <subject>${task.name}</subject>
      <text><![CDATA[Hey ${task.assignee},
Do not forget about task "${task.name}".
${task.description}

Sent by jBPM]]></text>
    </mail-template>

    <mail-template name="rectify-template">
      <to addresses="${addressee}" />
      <cc users="bb" groups="innerparty" />
      <bcc groups="thinkpol" />
      <subject>rectify ${newspaper}</subject>
      <text>${newspaper} ${date} ${details}</text>
    </mail-template>

  </process-engine-context>

</jbpm-configuration>
 

jbpm.mail.porperties

mail.smtp.host	localhost
mail.smtp.port	2525
mail.from		[email protected]

 

到这里启动tomcat 会报错。

原因是jbpm 要配置事务

可以在applicationContext_base.xml中加下事务配置

    <bean id="transactionManager"  
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
        <property name="sessionFactory">  
            <ref bean="sessionFactory" />  
        </property>  
    </bean>  
  
    
    <tx:advice id="txAdvice" transaction-manager="transactionManager">  
        <tx:attributes>  
            <tx:method name="add*" propagation="REQUIRED" />  
            <tx:method name="del*" propagation="REQUIRED" />  
            <tx:method name="update*" propagation="REQUIRED" />  
            <tx:method name="save*" propagation="REQUIRED" />  
            <tx:method name="*" read-only="true" />  
        </tx:attributes>  
    </tx:advice>  
  
   
    <aop:config>  
        <aop:pointcut id="allManagerMethod"  
            expression="execution(* com.vallen.dao.impl.ScheduleDAOImpl.*.*(..))" />  
        <aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice" />  
    </aop:config>  
 

到此配置 完毕。直接写例子测试吧

如果有需要已经配置好的完整工程的。可以留下你们的邮箱

参考http://fhn100.iteye.com/blog/643638

猜你喜欢

转载自vallen870201.iteye.com/blog/1059427
今日推荐