Spring Integration provides deep integration between jBPM 4 and the Spring framework. This allows jBPM 4 processes to leverage Spring features like dependency injection and transactions while maintaining the jBPM architecture. The integration configures jBPM services and transactions to work with Spring and adds activities that allow calling Spring beans and using EL expressions within processes. Tests can utilize Spring transaction management or run without transactions, and best practices are provided around configuration, testing, and further enhancement.
1 of 33
More Related Content
Spring integration with jBPM4
1. Spring Integration in jBPM 4 Andries Inz¨¦ [email_address] http://andries.inze.be
3. Content Why do we need Spring Integration? What¡¯s In It For Us? Architecture of jBPM 4 and Spring Integration Configuration Testing jBPM 4 with Spring Integration Q&A
4. Why do we need it? Previous efforts on jBPM 3 Spring Modules (jBPM 3.0-3.1 but not up!) Home brew frameworks http://www.jorambarrez.be
5. WIIFY Deep integration, making the necessary changes No need for hacks Part of the jBPM 4 test suite Expertise and insight of the jBPM Dev Team. What¡¯s In It For YOU ?
6. How much is realized? Scope 4.0.0.GA ? minimal scope jBPM 3 Further ? Easy extension and integration Spring Integration is ready but will not be fully supported in first release ? looking for feedback!
7. Content Why do we need Spring Integration? What¡¯s In It For Us? Architecture of jBPM 4 and Spring Integration Configuration Testing jBPM 4 with Spring Integration Q&A
10. jBPM 4 Architecture Dependency Lookup Environment Process Service Execution Service Management Service Hibernate Session Factory Transaction Manager ¡ Dependency resolution at runtime
15. Transaction Handling (2) Configuration Details for jBPM Process Service Execution Service History Service Command Service Standard Transaction Interceptor
16. Transaction Handling (3) Configuration Details for Spring Process Service Execution Service History Service Command Service Business Service Transaction Interceptor
17. Transaction Handling (4) A discrepancy between Spring and jBPM. Spring ? Transaction per service call jBPM ? Transaction per Command Spring Integration provides support for the two!
19. Activity Central focus of jBPM 4 <task />, <java />, <esb />, <sql />, ¡ SpringBeanActivity Expression Language ( JSR 223, Juel) #{myBean.property} < hql name = "count activities" var = "activities" unique = "true" > < query > select count(*) from org.jbpm.pvm.internal.model.ActivityImpl </ query > < transition to = "wait" /> </ hql >
20. SpringBeanActivity <? xml version = "1.0" encoding = "UTF-8" ?> < process name = "Spring" > < start > < transition to = "test" /> </ start > < spring name = " test " > < bean > testBean </ bean > < method > testMethodWithParameters </ method > < parameters > < string value = ¡°J-Spring" /> </ parameters > < transition to = ¡°finish" /> </ spring > < end name = ¡°finish" /> </ process >
21. Content Why do we need Spring Integration? What¡¯s In It For Us? Architecture of jBPM 4 and Spring Integration Configuration Testing jBPM 4 with Spring Integration Q&A
22. Configuration Minimal Spring Configuration < beans ... < bean id = "configuration" class = "org.jbpm.spring.cfg.SpringConfigurationFactoryBean" > < property name = "jbpmConfigurationLocation" value = ¡°my/jbpm.cfg.xml" /> </ bean > < bean id = "sessionFactory" class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean" > < property name = "configLocation" value = "classpath:my/hibernate.jbpm.cfg.xml" /> </ bean > < bean id = "transactionManager¡° class = "org.springframework.orm.hibernate3.HibernateTransactionManager" > < property name = "sessionFactory" ref = "sessionFactory" /> </ bean > < bean id = "dataSource" class = "org.springframework.jdbc.datasource.DriverManagerDataSource" > < property name = "driverClassName" value = "org.hsqldb.jdbcDriver" /> < property name = "url" value = "jdbc:hsqldb:mem:." /> < property name = "username" value = "sa" /> < property name = "password" value = "" /> </ bean > </ beans >
27. Content Why do we need Spring Integration? What¡¯s In It For Us? Architecture of jBPM 4 and Spring Integration Configuration Testing jBPM 4 with Spring Integration Q&A
28. AbstractTransactional SpringJbpmTestCase Only for Spring-Transaction strategy Transactional Rollback after test JbpmTestCase Only for jBPM-Transaction strategy Not transactional Performs client side cleanup ? destructive on existing data jBPM Testing
30. JbpmTestCase public class FindExecutionTest extends JbpmTestCase { public void testFindExecutionById() { deployJpdlXmlString( "<process name='p'>" + " <start>" + " <transition to='a' />" + " </start>" + " <state name='a' />" + "</process>" ); Execution execution = executionService .startProcessInstanceByKey( "p" ); // take the id and see if the execution service can still find it back execution = executionService .findExecution(execution.getId()); assertNotNull(execution); assertEquals( "a" , execution.getActivityName()); }
31. Best practice Split up the hibernate cfg files Use Spring transaction handling when possible Write small tests and reuse them Add test-applicationContext.xml to overwrite non-transactional activities (like file-IO)
32. Future Feedback from community Test if everything works as intended (Timers/async/¡) Test Spring 2.5 and up More SWF-like syntax DSL e.g. assertCurrentActivityEquals Mock sub processes ¡ Helping out?