`
loveExtJs
  • 浏览: 15670 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论
阅读更多
、下载jbpm4.3的包.下载地址.谷歌搜索.谢谢

2、在eclipse中安装jpdl插件.如何安装,请看上一篇博客

3、建立web项目,导入ssh框架所需要的包,以及jbpm包.如果你说你不会,那就甭干程序员了,哈哈

4、建立ssh框架的必要环境.如在web.xml中配置struts.xml,struts.xml中配置spring.xml(即applicationContext.xml)文件.如果你不会.那就看下面的代码.

     spring.xml文件中建立连接数据库的环境.如下:

    <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="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
      <value>classpath:net/*/webjbpm/dataResources.properties</value>
    </property>
  </bean>

<!--建立数据库环境-->

  <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName">
      <value>${JdbcDriverName}</value>
    </property>
    <property name="url">
      <value>${ConnectString}</value>
    </property>
    <property name="username">
      <value>${UserID}</value>
    </property>
    <property name="password">
      <value>${Password}</value>
    </property>
  </bean>

<!--创建流程引擎-->
  <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
  <bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
  <!--
  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
  <bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
  <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
   -->
  <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource"><ref bean="dataSource" /></property>
    <property name="hibernateProperties">
      <props>
  <!--<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>-->
  <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
      </props>
    </property>
    <property name="mappingResources">
      <list>
        <value>net/bolue/webjbpm/Apply.hbm.xml</value>

<!--导入jbpm所需要的hbm.xml文件-->
            <value>jbpm.repository.hbm.xml</value>
            <value>jbpm.execution.hbm.xml</value>
            <value>jbpm.history.hbm.xml</value>
            <value>jbpm.task.hbm.xml</value>
            <value>jbpm.identity.hbm.xml</value>       
      </list>
    </property>
  </bean>
  <bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
      <ref bean="sessionFactory" />
    </property>
  </bean>

  <bean id="txProxyTemplate" abstract="true"
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager">
      <ref bean="transactionManager" />
    </property>
    <property name="transactionAttributes">
      <props>
        <prop key="*">PROPAGATION_REQUIRED</prop>
      </props>
    </property>
  </bean>
</beans>

  在struts.xml最后action-mapping下面加上如下代码:

  <controller inputForward="true"
    processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
  <message-resources
    parameter="cn.com.bolue.basic.resource.ApplicationResources" />
  <plug-in
    className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation" value="classpath:spring.xml;classpath:spring-process.xml" />
  </plug-in>

注意,为什么一定要在这个里面加上classpath呢,那是因为spring.xml(就是applicationContext.xml)文件需要放在src的文件夹下面,主要是jbpm中的jbpm.cft.xml文件需要放在src下面,要不然路径会很让人头疼。我整了很多天,也没有整清楚,建议你不要费那脑劲想了。能用就行。

   web.xml中配上struts.xml文件,这不用教吧,作为一个用框架熟练的程序员,这都不会.那还敢干程序吗。

   下面再是action中的文件,在action中代码如下:

   private ProcessEngine processEngine =  null ;
private RepositoryService repositoryService = null;
private ExecutionService executionService = null;
private ProcessInstance processInstance = null;
private TaskService taskService = null;
private Task task = null;
private Execution execution = null;
private List list = null;
private List<Task> taskList = null;
private String url = "";

    /* 初始化ProcessEngine. */ 
public void setServlet(ActionServlet actionServlet) {  
   super.setServlet(actionServlet);  
         if (actionServlet != null) {  
          processEngine = new Configuration().buildProcessEngine();  
           repositoryService = processEngine.getRepositoryService();  
           executionService = processEngine.getExecutionService();  
           taskService = processEngine.getTaskService();  
         }
}

下一下:

jbpm.cfg.xml文件写入:

  <import resource="jbpm.default.cfg.xml" />
  <import resource="jbpm.businesscalendar.cfg.xml" />

<!--一般是jbpm.tx.hibernate.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" />

  <!-- 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" />

<!--注意,加此处是因为如果不是默认的applicationContext.xml文件就需要加以下代码以及路径了-->
  <process-engine-context>
    <string name="spring.cfg" value="classpath:spring.xml" />
</process-engine-context>

后面,就可以随心所欲的使用jbpm了.框架与JBPM4.3整合完毕。谢谢..其他的问题自行解决.

最后一点注意,spring的业务类注入时要与spring.xml(applicationContext.xml)分开注入,不要放在一个配置文件里面,要不然,会一直循环启动的.


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/polisman/archive/2010/04/24/5525216.aspx



第一种配置:src下提供jbpm.cfg.xml、jbpm.hibernate.cfg.xml、bean.xml
jbpm.cfg.xml
<jbpm-configuration>
      <import resource="jbpm.default.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.businesscalendar.cfg.xml" />
      <import resource="jbpm.console.cfg.xml" />
      <!--  <import resource="jbpm.jobexecutor.cfg.xml" />  -->
      <process-engine-context>
            <string name="spring.cfg" value="beans.xml" /><!-- spring.cfg的默认值为"applicationContext.xml" -->
      </process-engine-context>
</jbpm-configuration>
jbpm.hibernate.cfg.xml
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost/jbpm</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">123</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
        <property name="hibernate.format_sql">true</property>
        <!--<property name="hibernate.current_session_context_class">thread</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>
bean.xml
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<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" />
      <property name="dataSource" ref="dataSource" />
</bean> 
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="com.mysql.jdbc.Driver" />
      <property name="url" value="jdbc:mysql://localhost/jbpm" />
      <property name="username" value="root" />
      <property name="password" value="123" />
</bean>需要说明:

jbpm.cfg.xml文件中引入<import resource="jbpm.tx.spring.cfg.xml" />意思是把jBPM4.3的事务交由Spring来管理,这时你不能再引入<import resource="jbpm.tx.hibernatecfg.xml" />。
jbpm.cfg.xml文件中spring.cfg值是你配置sessionFactory的Spring文件,默认applicationContext.xml。
jbpm.hibernate.cfg.xml 文件中hibernate.dialect中设置为org.hibernate.dialect.MySQLInnoDBDialect,关于这一点网上其它帖子说的已经很清楚了。
jbpm.hibernate.cfg.xml 文件中不要配置这个属性:<property name="hibernate.current_session_context_class">thread</property>我一开始就是因为配置了这个选项,导致集成的时候总是报出各种异常,弄 的我糊里糊涂的。最后在jBPM的社区中看到了一个帖子才知道怎么回事。原来在Hibernate集成Spring的时候hibernate.current_session_context_class的值必须被设置为SpringSessionContext的相应值,而这 个工作,LocalSessionFactoryBean自动的就帮我们完成了,所以我们不必再额外配置了。
jBPM与Spring整合要达到的目的:把jBPM的事务交由Spring来管理,由于jBPM底层应用Hibernate来实现,所以整合的一个表征是把jBPM管理的SessionFactory交由Spring来注入。这样在SSH框架中我们操作的就是同一个SessionFactory对象了.
第二种配置:src下只提供jbpm.cfg.xml和bean.xml
jbpm.cfg.xml<jbpm-configuration>
      <import resource="jbpm.default.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.businesscalendar.cfg.xml" />
      <import resource="jbpm.console.cfg.xml" />
      <!--  <import resource="jbpm.jobexecutor.cfg.xml" />  -->
      <process-engine-context>
            <string name="spring.cfg" value="beans.xml" /><!-- spring.cfg的默认值 为"applicationContext.xml" -->
      </process-engine-context>
</jbpm-configuration>
beans.xml<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="hibernateProperties">
            <props>
                  <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
                  <prop key="hibernate.show_sql">true</prop>
                  <prop key="hibernate.hbm2ddl.auto">update</prop>
                  <!--<prop key="hibernate.current_session_context_class">thread</prop>-->
            </props>
      </property>
      <property name="mappingResources">
            <list>
                  <value>jbpm.repository.hbm.xml</value>
                  <value>jbpm.execution.hbm.xml</value>
                  <value>jbpm.history.hbm.xml</value>
                  <value>jbpm.task.hbm.xml</value>
                  <value>jbpm.identity.hbm.xml</value>                
            </list>
      </property>
</bean> 
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="com.mysql.jdbc.Driver" />
      <property name="url" value="jdbc:mysql://localhost/jbpm" />
      <property name="username" value="root" />
      <property name="password" value="123" />
</bean>
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

    已经交叉编译好的arm64版本的qt5.12.1以及qtmqtt的完整产物

    ICU .................................... no Tracing backend ........................ Logging backends: journald ............................. no syslog ............................... no slog2 ...

    DM8_SQL语言使用手册.pdf

    2.2 参考脚本 ......................................................................................................................26 2.2.1 创建示例库 ....................................................

    Cocos-Creator开发(来自于网络).pdf

    目录.....................................................................................................................................................2 第一章 JavaScript 快速入门......................

    exe程序反编译 图标修改 里面包括eXeScope AutoDec Restorator ResHacker .......

    exe程序反编译 图标修改 里面包括eXeScope AutoDec ResHacker ....... exe程序反编译 图标修改 里面包括eXeScope AutoDec ResHacker ....... exe程序反编译 图标修改 里面包括eXeScope AutoDec ResHacker ....... ...

    Springer.The.Developer’s.Guide.to.Debugging.2008.pdf

    1 You Write Software; You have Bugs . . . . . . . . ....2 A Systematic Approach to Debugging .... ....2.2 Making the Most of Your Opportunities ....2.3 13 Golden Rules ....2.3.1 Understand the Requirements ....

    ........2133

    ..........2313313312123213231123231

    IT上网行为管理修改...........本共9页.pdf

    IT上网行为管理修改...........本共9页.pdf.zip

    高级C语言.PDF

    位域 ................................................................................................................................................ 52 14. C语言函数二维数组传递方法 ...................

    大数据学习笔记.pdf

    第一部分 Spark学习 ....................................................................................................................... 6 第1章 Spark介绍 ..............................................

    OSS-SDK.pdf

    2.1 前⾔............................................................................................................2 2.2 安装.............................................................................

    懂得都懂.......h9cQu0a.apk

    懂得都懂.......h9cQu0a.apk

    写操作文档使用图片...................................

    写操作文档使用图片...................................

    唱歌效果.kx ................................

    唱歌效果.kx ...........................

    托利多_bCom操作手册.pdf

    概述 ..................................................................................................................................... 1 1.1 产品特性..................................................

    基于ARM的五子棋游戏设计.pdf

    棋游戏概述...............................................................................................................7 2.1.1 五子棋规则................................................................

    Geoserver用户手册

    1 Introduction 3 1.1 Overview . . . . . . . . ....1.2 History ....1.3 Getting involved ....1.4 License ....2.1 Windows installer ....2.2 Windows binary ....2.3 Mac OS X installer ....2.4 Mac OS X binary ....

    曲靖人才求职网站设计.doc

    网站功能模块实现.................................................................................................224.1 求职者注册与登录模块................................................................

    基于jsp的咖啡馆管理系统源码数据库论文.doc

    2.1 系统功能需求...............................................................................................................................................9 2.1.1 用户管理模块........................

    信息安全风险评估报告.pdf

    1 概述 ................................................................................................................................................. 5 1.1 项目背景 ..................................

Global site tag (gtag.js) - Google Analytics