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

          主站蜘蛛池模板: 彰武县| 阿瓦提县| 柳林县| 读书| 盱眙县| 许昌市| 奈曼旗| 巴中市| 连云港市| 五原县| 湖州市| 织金县| 云梦县| 江津市| 长白| 邻水| 通道| 巫山县| 龙川县| 会理县| 河南省| 嵊泗县| 天津市| 澜沧| 砚山县| 乐安县| 赤城县| 疏附县| 遵义市| 龙泉市| 汉阴县| 大冶市| 额敏县| 苏州市| 环江| 南京市| 正阳县| 麻栗坡县| 西贡区| 七台河市| 沙洋县|