JBPM与SSH架构融合

1.  加入spring-modules-jbpm31.jar
2.  在spirng中配置jbpmConfiguration
    <!-- jbpm configuration -->
    <bean id="jbpmConfiguration" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
       <property name="sessionFactory" ref="sessionFactory" />
       <property name="configuration" value="classpath:jbpm.cfg.xml" />
    <!--   <property name="createSchema" value="true" />  -->
    </bean>
   
    <bean id="jbpmTemplate" class="org.springmodules.workflow.jbpm31.JbpmTemplate">
       <constructor-arg index="0" ref="jbpmConfiguration" />
    </bean>
    <!-- end jbpm configuration -->


2.如果Service中要用到工作流,将jbpmConfiguration注入到其属性中。
<bean id="xxxService" class="com.business.xxxServiceImpl">
       <property name="xxxDao">
           <ref bean="xxxDao" />
       </property>
       <property name="jbpmConfiguration">
           <ref bean="jbpmConfiguration" />
       </property>
    </bean>

3.如果想在项目部署时,就将流程自动部署到数据库中,则加上配置
<!-- reading jBPM process definitions -->
    <bean id="baoxiao"
       class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean">
       <property name="definitionLocation"
           value="classpath:com/workflow/flowchart/baoxiao/processdefinition.xml" />
    </bean>
    <bean id="caiwu"
       class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean">
       <property name="definitionLocation"
           value="classpath:com/workflow/flowchart/caiwu/processdefinition.xml" />
    </bean>
    <!-- jbpm configuration -->
    <bean id="jbpmConfiguration"
       class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
       <property name="sessionFactory" ref="sessionFactory" />
       <property name="configuration" value="classpath:jbpm.cfg.xml" />
       <property name="createSchema" value="true" />
       <property name="processDefinitions">  
           <list>
              <ref local="baoxiao" />
              <ref local="caiwu" />
           </list>
       </property>
    </bean>
 
    <bean id="jbpmTemplate"
       class="org.springmodules.workflow.jbpm31.JbpmTemplate">
       <constructor-arg index="0" ref="jbpmConfiguration" />
       <constructor-arg index="1" ref="baoxiao" />
       <constructor-arg index="1" ref="caiwu" />
    </bean>
    <!-- end jbpm configuration -->
 

4.配置workflow中action,assignment,decision等,同spring中普通的javaBean配置一样,采用依赖注入。

5.配置好后,在具体的processdefinition.xml中,引用这个类时,就有点区别:
 
 <assignment class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
            <targetBean>userAssignment</targetBean> 
            <factoryKey>jbpmConfiguration</factoryKey>
         </assignment>
<handler class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy">
        <targetBean>processDecision</targetBean>
        <factoryKey>jbpmConfiguration</factoryKey>
     </handler>
 
  <action name="action1" class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy">
         <targetBean>processResult</targetBean>
            <factoryKey>jbpmConfiguration</factoryKey>
         </action>
 


6.注意
config-type有4种配置类型:
1)Field------直接给目标类的字段赋值。 字段没有set/get方法,不是一个属性。该类也不是一个Bean。这应该是使用CGLIB字节码生成实现的。也可能使用反射。
<assignment class="com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler">
            <a>a</a>
         </assignment>
2)Bean------通过set方法赋值。   这和Spring的<property>是一致的。
<assignment class="com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" config-type="bean">
            <a>a</a>
         </assignment>
3)constructor-----传给构造器的参数。
<assignment class="com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" config-type="constructor">
            a
         </assignment>
4)compatibility-----兼容性
<assignment class="com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" config-type="configuration-property">
            a
         </assignment>
默认的配置是默认的构造

你可能感兴趣的:(java,spring,workflow,jbpm,ssh)