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 阅读(457) 评论(0)  编辑  收藏 所属分类: jbpm


只有注册用户登录后才能发表评论。


网站导航: