Beruflich Dokumente
Kultur Dokumente
This is a simple example of an app that runs a simple process and shows how to integrate
Spring with Jbpm
The view technology chosen is JSF and the database chosen is MySql.
Requirements
The basic requirement is that you have running a MySql database that connects to your
schema.
House Cleaning
The application described can be downloaded (maven project) and then you can mvn clean
install to create
Your may need to manually install the jbpm lib files jbpm-3.1.2.jar and jbpm-
identity-3.1.2.jar for your
maven to get them correctly. Then modify the pom file accordingly that is,
<dependency>
<groupId>jboss</groupId>
<artifactId>jbpm</artifactId>
<version>3.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jbpm-identity</artifactId>
<version>3.1.2</version>
<scope>compile</scope>
</dependency>
JBPM Tables
For starters we need to have the jbpm tables into your MySql database.
The easiest way I found is to let hibernate create them for you: (Using the attached project)
1. grab a hold on WEB-INF/jdbc.properties file and modify the required fields, save the
file.
1.That is, make sure you modified username and password fields
2. Open up WEB-INF/applicationWebContext.xml and uncomment <prop
key="hibernate.hbm2ddl.auto">create</prop>
sure you can see a large array of tables created eg JBPM_PROCESSDEFINITION etc..
1. Shut down your Tomcat Server, go back to your project and comment out
the <prop key="hibernate.hbm2ddl.auto">create</prop> in your WEB-INF/
applicationWebContext.xml file
of your processes.
web.xml
Things to note for
• We use JSF 1.1 and is configured in the web.xml file with only one faces-config file
• The Faces Servlet uses the url pattern of .faces meaning our applyHolidayForm.jsp
maps to
applyHolidayForm.faces
applicationWebContext.xml
The way Spring knows of our process definition location is via the holidayProcessDefinition
bean
jbpmTemplate is the main helper bean that you use to interface to your process
jbpmSessionFactory manages the session note that its name MUST be sessionFactory
otherwise it wont
the sessionFactory also knows about the hibernate mapping tables via hibernate.cfg.xml file
and knows
txManager manages the hibernate transactions and is used by our DAOs / Service beans it
has
We first develop our DAO target bean which has autowire by name. This means that our
actual DAO needs to have
</props>
</property>
</bean>
Note that it has a reference to :
• txManager bean
• processFormDAOTarget bean
At the moment I havent caught up with how do you let Jbpm to send email notifications
So for the meantime you can use Spring Mail support service.
The basic idea is this. I want an email notification to be triggered upon entering a decision
node.
In essence after doing my decision logic in the node I want to send a corresponding email
that will inform the
However I wired up my email using Spring and as such Spring needs to load the email
manager bean on its
context loader. So how to let my decision node know about my email manager in Spring?
<decision name="evaluateLeave">
<handler class="au.com.qtc.simpleForms.jbpm.decision.EvaluateLeaveDecisionHandler"></handler>
<transition to="end" name="yes">
<action class="au.com.qtc.simpleForms.jbpm.action.NotifyAboutLeaveActionHandler"></action>
</transition>
<transition to="giveDonuts" name="no">
<action class="au.com.qtc.simpleForms.jbpm.action.NotifyAboutLeaveActionHandler"></action>
</transition>
</decision>
I want my NotifyAboutLeaveActionHandler to know about my mail manager Spring bean.
<decision name="evaluateLeave">
<handler class="au.com.qtc.simpleForms.jbpm.decision.EvaluateLeaveDecisionHandler"></handler>
<transition to="end" name="yes">
<action name="notificationAction" config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy">
<targetBean>notifyAboutLeaveActionHandler</targetBean>
</action>
</transition>
<transition to="giveDonuts" name="no">
<action name="notificationAction" config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy">
<targetBean>notifyAboutLeaveActionHandler</targetBean>
</action>
</transition>
</decision>
Note the notificationAction nae refers to a spring module JbpmHandlerProxy bean. which as
the name suggest
as such it can now inject any Spring declared beans. As such I am now able to inject the
appropriate
mailManager bean.