提前试用spring 集成 jbpm4
在jbpm4的项目中,在下面的网址中看到了简单集成spring 和 jbpm4的集成方法。
http://www.slideshare.net/guest8d4bce/spring-integration-with-jbpm4
jbpm4的分支中已经有了集成的代码
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbpm_svn/jbpm4/branches/ainze/
唯一的遗憾就是代码目前还没有和最新的代码同步,于是乎就简单的对这两块代码先做了些合并工作.
数据库: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());
}
}
我昨天下的jBPM-4.1中,只有SpringConfiguration了。 比较惊讶的是有这么一段: public Object get(String key) { if (applicationContext.containsBean(key)) { return applicationContext.getBean(key); }
} jBPM怎么能让spring卡在前头呢?好得也要让jbpm的ioc容器配置为主啊, 后来想想,可能是因为jBPM的ioc支持延迟创建害的。
在运行测试代码的时候报错: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpmConfiguration' defined in class path resource : Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class : Constructor threw exception; nested exception is org.jbpm.api.JbpmException: error: no element parser for tag repository-service in category descriptor error: no element parser for tag repository-cache in category descriptor error: no element parser for tag execution-service in category descriptor error: no element parser for tag history-service in category descriptor error: no element parser for tag management-service in category descriptor error: no element parser for tag identity-service in category descriptor error: no element parser for tag task-service in category descriptor error: no element parser for tag script-manager in category descriptor error: no element parser for tag authentication in category descriptor error: no element parser for tag id-generator in category descriptor error: no element parser for tag types in category descriptor error: no element parser for tag address-resolver in category descriptor error: no element parser for tag business-calendar in category descriptor error: no element parser for tag mail-template in category descriptor error: no element parser for tag mail-template in category descriptor error: no element parser for tag command-service in category descriptor error: no element parser for tag repository-session in category descriptor error: no element parser for tag db-session in category descriptor error: no element parser for tag message-session in category descriptor error: no element parser for tag timer-session in category descriptor error: no element parser for tag history-session in category descriptor error: no element parser for tag mail-session in category descriptor error: no element parser for tag hibernate-session in category descriptor
这是什么原因?