JBPM3.2GA 整合SSH

【转】JBPM3.2GA 整合SSH .
2011-03-04 18:53 177人阅读 评论(0) 收藏 举报
之前本来用的是JBPM4.4的,并且SSH都整合好了,当时我们公司产品为了兼容性考虑用的是JDK1.4, JBPM4.4至少是需要JDK5以上的版本的。 所以就将JBPM版本换成了3.2GA(http://sourceforge.net/上有下载),在将JBPM3.2GA和Spring1.2 + Hibernate3.1 + webwork2整合的时候遇到了不少麻烦,上网收集了很多资料,在这里总结一下,帮助那些JBPM的初学者和方便以后查阅。

在这里需要四个Jar包,spring-modules-jbpm*.jar ,jbpm-3.2GA.jar ,jbpm-identity.jar ,bsh.jar。

1,在applicationContext.xml中这么配置

  <bean id="jbpmConfiguration" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">         <property name="sessionFactory" ref="sessionFactory" />        <property name="configuration" value="classpath:jbpm.cfg.xml" />    </bean>     <bean id="jbpmTemplate" class="org.springmodules.workflow.jbpm31.JbpmTemplate">         <property name="jbpmConfiguration" ref="jbpmConfiguration"></property>     </bean> 这样我们就可以通过依赖注入,在程序中使用jbpmConfiguration和jbpmTemplate了。

2,在applicationContext.xml中,我们可以看到jbpmConfiguration是需要依赖jbpm.cfg.xml的(<property name="configuration" value="classpath:jbpm.cfg.xml" />)

这个文件我们可以在jbpm-3.2GA.jar中找到(在包org.jbpm下default.jbpm.cfg.xml), 由于我们的数据库配置是在hibernate.cfg.xml(或者是applicationContext.xml)中配置好了的,

所以我们需要将org.jbpm下的default.jbpm.cfg.xml复制出来,然后去掉其中的一句话<stringname="resource.hibernate.cfg.xml" value="hibernate.cfg.xml"/> 就可以了。然后将其重命名为jbpm.cfg.xml 放在src目录下,如果没有这个文件的话,jbpm会默认调用org.jbpm下的default.jbpm.cfg.xml。

修改之后的jbpm.cfg.xml如下

<jbpm-configuration>  <!--     This configuration is used when there is no jbpm.cfg.xml file found in the     root of the classpath.  It is a very basic configuration without persistence    and message services.  Only the authorization service installed.    You can parse and create processes, but when you try to use one of the     unavailable services, you'll get an exception.  -->    <jbpm-context>    <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />    <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />    <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />    <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />    <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />    <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />  </jbpm-context>  <!-- configuration property used by persistence service impl org.jbpm.persistence.db.DbPersistenceServiceFactory -->  <!-- <string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" /> -->  <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->  <string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" />  <string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />  <string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" />  <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />  <string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" />  <string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" />  <string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />  <string name="resource.mail.templates" value="jbpm.mail.templates.xml" />  <int    name="jbpm.byte.block.size" value="1024" singleton="true" />  <bean   name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />  <bean   name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />  <string name="jbpm.mail.smtp.host" value="localhost" />  <bean   name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" />  <string name="jbpm.mail.from.address" value="jbpm@noreply" />    <bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor">    <field name="jbpmConfiguration"><ref bean="jbpmConfiguration" /></field>    <field name="name"><string value="JbpmJobExecutor" /></field>    <field name="nbrOfThreads"><int value="1" /></field>    <field name="idleInterval"><int value="5000" /></field>    <field name="maxIdleInterval"><int value="3600000" /></field> <!-- 1 hour -->    <field name="historyMaxSize"><int value="20" /></field>    <field name="maxLockTime"><int value="600000" /></field> <!-- 10 minutes -->    <field name="lockMonitorInterval"><int value="60000" /></field> <!-- 1 minute -->    <field name="lockBufferTime"><int value="5000" /></field> <!-- 5 seconds -->  </bean></jbpm-configuration>3,添加jbpm数据表的映射文件。

在applicationContext.xml添加如下配置,这里就不详细描述了,会hibernate,spring的同学都应该很熟悉了。直接贴代码:

          <value>org/jbpm/graph/def/Action.hbm.xml</value>                <value>org/jbpm/graph/action/Script.hbm.xml</value>                <value>org/jbpm/db/hibernate.queries.hbm.xml</value>                                <value>org/jbpm/graph/def/ProcessDefinition.hbm.xml</value>                <value>org/jbpm/graph/def/Node.hbm.xml</value>                <value>org/jbpm/graph/def/Transition.hbm.xml</value>                <value>org/jbpm/graph/def/Event.hbm.xml</value>                                <value>org/jbpm/graph/def/SuperState.hbm.xml</value>                <value>org/jbpm/graph/def/ExceptionHandler.hbm.xml</value>                <value>org/jbpm/instantiation/Delegation.hbm.xml</value>                        <value>org/jbpm/graph/node/StartState.hbm.xml</value>                <value>org/jbpm/graph/node/EndState.hbm.xml</value>                <value>org/jbpm/graph/node/ProcessState.hbm.xml</value>                <value>org/jbpm/graph/node/Decision.hbm.xml</value>                <value>org/jbpm/graph/node/Fork.hbm.xml</value>                <value>org/jbpm/graph/node/Join.hbm.xml</value>                                <value>org/jbpm/graph/node/State.hbm.xml</value>                <value>org/jbpm/graph/node/TaskNode.hbm.xml</value>                        <value>org/jbpm/context/def/ContextDefinition.hbm.xml</value>                <value>org/jbpm/context/def/VariableAccess.hbm.xml</value>                        <value>org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml</value>                <value>org/jbpm/taskmgmt/def/Swimlane.hbm.xml</value>                <value>org/jbpm/taskmgmt/def/Task.hbm.xml</value>                <value>org/jbpm/taskmgmt/def/TaskController.hbm.xml</value>                        <value>org/jbpm/module/def/ModuleDefinition.hbm.xml</value>                        <value>org/jbpm/bytes/ByteArray.hbm.xml</value>                        <value>org/jbpm/file/def/FileDefinition.hbm.xml</value>                        <value>org/jbpm/scheduler/def/CreateTimerAction.hbm.xml</value>                <value>org/jbpm/scheduler/def/CancelTimerAction.hbm.xml</value>                        <value>org/jbpm/graph/exe/Comment.hbm.xml</value>                <value>org/jbpm/graph/exe/ProcessInstance.hbm.xml</value>                <value>org/jbpm/graph/exe/Token.hbm.xml</value>                <value>org/jbpm/graph/exe/RuntimeAction.hbm.xml</value>                        <value>org/jbpm/module/exe/ModuleInstance.hbm.xml</value>                 <value>org/jbpm/context/exe/ContextInstance.hbm.xml</value>                <value>org/jbpm/context/exe/TokenVariableMap.hbm.xml</value>                <value>org/jbpm/context/exe/VariableInstance.hbm.xml</value>                <value>org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml</value>                <value>org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml</value>                <value>org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml</value>                <value>org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml</value>                <value>org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml</value>                <value>org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml</value>                <value>org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml</value>                <value>org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml</value>                        <!-- job mapping files -->                <value>org/jbpm/job/Job.hbm.xml</value>                <value>org/jbpm/job/Timer.hbm.xml</value>                <value>org/jbpm/job/ExecuteNodeJob.hbm.xml</value>                <value>org/jbpm/job/ExecuteActionJob.hbm.xml</value>                        <value>org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml</value>                <value>org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml</value>                <value>org/jbpm/taskmgmt/exe/PooledActor.hbm.xml</value>                <value>org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml</value>                        <value>org/jbpm/logging/log/ProcessLog.hbm.xml</value>                <value>org/jbpm/logging/log/MessageLog.hbm.xml</value>                <value>org/jbpm/logging/log/CompositeLog.hbm.xml</value>                <value>org/jbpm/graph/log/ActionLog.hbm.xml</value>                <value>org/jbpm/graph/log/NodeLog.hbm.xml</value>                <value>org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml</value>                <value>org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml</value>                <value>org/jbpm/graph/log/ProcessStateLog.hbm.xml</value>                <value>org/jbpm/graph/log/SignalLog.hbm.xml</value>                <value>org/jbpm/graph/log/TokenCreateLog.hbm.xml</value>                <value>org/jbpm/graph/log/TokenEndLog.hbm.xml</value>                <value>org/jbpm/graph/log/TransitionLog.hbm.xml</value>                <value>org/jbpm/context/log/VariableLog.hbm.xml</value>                <value>org/jbpm/context/log/VariableCreateLog.hbm.xml</value>                <value>org/jbpm/context/log/VariableDeleteLog.hbm.xml</value>                <value>org/jbpm/context/log/VariableUpdateLog.hbm.xml</value>                <value>org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml</value>                <value>org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml</value>                <value>org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml</value>                <value>org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml</value>                <value>org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml</value>                <value>org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml</value>                <value>org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml</value>                <value>org/jbpm/taskmgmt/log/TaskLog.hbm.xml</value>                <value>org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml</value>                <value>org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml</value>                <value>org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml</value>                <value>org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml</value>                <value>org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml</value>                <value>org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml</value>现在所有的配置都已经OK了!

下面我把那4个jar包也上传一下 ,建议使用我上传的jar包,要不然可能会出错的!

现在地址:http://files.cnblogs.com/gaoyoubo/jbpm.rar

你可能感兴趣的:(jbpm)