12 Replies Latest reply on Nov 25, 2005 4:03 AM by kamaljeet sandhu

    Spring JBPM support

    Yunfeng Hou Newbie

      I would like to share my implementation for the spring support. Here's the design consideration:

      1. make jbpm session factory a factory bean.
      2. make use of HibernateTemplate rather than access the Session object
      3. let spring AOP to handle the transaction issue.

      I use open session in view patten to start a hibernate session when a jbpm session is instantiated, and release the hibernate session from current thread when the jbpm session is closed.

      The implementation includes the following classes:
      1. SpringJbpmSessionFactory: a factory bean can generate SpringJbpmSession objects.
      2. SpringJbpmSession: when instantiated, hibernate session will be bound to current thread, until close() is called
      3. JbpmSessionFilter: an servlet filter will start a SpringJbpmSession when receive a http request and close it when request is served.
      4. JbpmSessionHelper: an helper class to popup current session used when close a jbpm session.

      The spring config would be

       <bean id="hbConfiguration"
       class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
       <property name="targetObject" ref="&amp;hbSessionFactory" />
       <property name="targetMethod" value="getConfiguration" />
       </bean>
      
      
       <bean id="jbpmSessionFactory"
       class="org.jbpm.spring.SpringJbpmSessionFactory">
       <constructor-arg ref="hbConfiguration" />
       <constructor-arg ref="hbSessionFactory" />
       <property name="hibernateTemplate" ref="hibernateTemplate" />
       <property name="transactionManager" ref="transactionManager" />
       </bean>
      
      


      Please download the source code from:
      http://triload.com/downloads/spring-jbpm/


      Yunfeng Hou