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集成的最簡配置
- <!-- jbpm4配置 -->
- <bean id="configuration" class="org.jbpm.spring.cfg.SpringConfigurationFactoryBean">
- <property name="jbpmConfigurationLocation" value="jbpm.cfg.xml"></property>
- <property name="sessionFactory" ref="sessionFactory" />
- </bean>
測試代碼--org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase(author Andries Inze)
- public class SimpleProcessTest extends AbstractTransactionalSpringJbpmTestCase{
- @Override
- protected String[] getConfigLocations() {
- return new String[]{"classpath:test-context-hibernate.xml"};
- }
- public void test1(){
- deployJpdlXmlString(
- "<process name='p'>"
- + " <start>"
- + " <transition to='a'/>"
- + " </start>"
- + " <state name='a'>"
- + " <transition to='b'/>"
- + "</state>"
- + " <state name='b'>"
- + " <transition to='c'/>"
- + "</state>"
- + " <state name='c'/>"
- + "</process>");
- Execution execution = executionService.startProcessInstanceByKey("p");
- execution = executionService.findExecutionById(execution.getId());//.findExecution(execution.getId());
- assertNotNull(execution);
- assertEquals("a", execution.getActivityName());
- //a流向b
- execution = executionService.signalExecutionById(execution.getId());
- assertNotNull(execution);
- assertEquals("b", execution.getActivityName());
- //b流向c
- execution = executionService.signalExecutionById(execution.getId());
- assertNotNull(execution);
- assertEquals("c", execution.getActivityName());
- //再次啟動流程
- execution = executionService.startProcessInstanceByKey("p");
- //第三次啟動流程
- execution = executionService.startProcessInstanceByKey("p");
- assertEquals(3,executionService.createProcessInstanceQuery().list().size());
- }
- }
posted on 2009-10-12 16:00 vanlin 閱讀(480) 評論(0) 編輯 收藏 所屬分類: jbpm