Vanlin Study Club

          Java Js Flex

          Spring integration with jBPM4{PPT}

          Spring integration with jBPM4



























          來自http://zhyi-12.javaeye.com/blog/375061 的實現

          數據庫:mysql

          集成項:spring2.5  hibernate3.3  jbpm4

          相關的類:

          org.jbpm.pvm.internal.cfg.JbpmConfiguration (其中的buildProcessEngine方法 有些東西沒有合并進去,可能會有些問題 ,有興趣的可以探尋下)

          org.jbpm.pvm.internal.cfg.SpringConfiguration(Tom Baeyens在TODO中,這個是ainze寫的)

           

          org.jbpm.pvm.internal.env.SpringPvmEnvironment(ainze)

           

          org.jbpm.pvm.internal.spring.SpringConfigurationFactoryBean(ainze)

           

           

          (jbpm.cfg.xml中只需要注釋掉hibernate的配置即可)

           

          spring 配置--使用了SpringConfigurationFactoryBean(調整自ainze)的方式配置時 這個就是spring集成的最簡配置

          Xml代碼 
          1. <!-- jbpm4配置   -->  
          2.     <bean id="configuration" class="org.jbpm.spring.cfg.SpringConfigurationFactoryBean">  
          3.         <property name="jbpmConfigurationLocation" value="jbpm.cfg.xml"></property>  
          4.         <property name="sessionFactory" ref="sessionFactory" />  
          5.     </bean>  

           

          測試代碼--org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase(author Andries Inze)

          Java代碼 
          1. public class SimpleProcessTest  extends AbstractTransactionalSpringJbpmTestCase{  
          2.    
          3.  @Override  
          4.  protected String[] getConfigLocations() {  
          5.   return new String[]{"classpath:test-context-hibernate.xml"};  
          6.  }  
          Java代碼 
          1.  public void test1(){  
          2.    deployJpdlXmlString(   
          3.      "<process name='p'>"   
          4.      + " <start>"   
          5.      + "  <transition to='a'/>"  
          6.      + " </start>"   
          7.      + " <state name='a'>"   
          8.      + "   <transition to='b'/>"  
          9.      + "</state>"  
          10.      + " <state name='b'>"   
          11.      + "   <transition to='c'/>"  
          12.      + "</state>"  
          13.      + " <state name='c'/>"   
          14.       + "</process>");  
          15.      
          16.      
          17.    Execution execution = executionService.startProcessInstanceByKey("p");  
          18.    execution = executionService.findExecutionById(execution.getId());//.findExecution(execution.getId());  
          19.    assertNotNull(execution);  
          20.    assertEquals("a", execution.getActivityName());  
          21.      
          22.   //a流向b   
          23.    execution = executionService.signalExecutionById(execution.getId());  
          24.    assertNotNull(execution);  
          25.    assertEquals("b", execution.getActivityName());  
          26.      
          27.   //b流向c   
          28.    execution = executionService.signalExecutionById(execution.getId());  
          29.    assertNotNull(execution);  
          30.    assertEquals("c", execution.getActivityName());  
          31.    //再次啟動流程  
          32.    execution = executionService.startProcessInstanceByKey("p");  
          33.   //第三次啟動流程  
          34.    execution = executionService.startProcessInstanceByKey("p");  
          35.      
          36.    assertEquals(3,executionService.createProcessInstanceQuery().list().size());  
          37.  }  
          38. }  

           

          posted on 2009-10-12 16:00 vanlin 閱讀(480) 評論(0)  編輯  收藏 所屬分類: jbpm

          主站蜘蛛池模板: 赣州市| 桃源县| 新邵县| 昭通市| 东乡县| 中宁县| 电白县| 肃宁县| 闵行区| 简阳市| 南木林县| 宾阳县| 台湾省| 吉林省| 闽清县| 阳朔县| 丽水市| 万州区| 贡嘎县| 日喀则市| 晋宁县| 长沙市| 安阳县| 建昌县| 景谷| 内江市| 永城市| 西丰县| 错那县| 凉城县| 咸阳市| 金门县| 孟村| 湖州市| 雷山县| 农安县| 南乐县| 濮阳市| 武陟县| 乐平市| 开化县|