JBPM与SSH架构融合

    技术2022-05-19  25

    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 >

    默认的配置是默认的构造

     


    最新回复(0)