Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
AmeerAhmed
IntegratingJBPMIntoA...
IntegratingJBPMIntoA...




JSPWiki v2.2.33

[RSS]


Hide Menu

IntegratingJBPMIntoAppFusePartDeux


Difference between version 41 and version 6:

At line 1 changed 1 line.
__Part II:__ [Integrating jBPM into AppFuse - Part Deux] - A HowTo for enhancing jBPM Support into AppFuse.
__Part I:__ [Integrating jBPM into AppFuse] - Integrate jBPM Support (via Spring-Modules) into AppFuse.\\
__Part II:__ [Integrating jBPM into AppFuse Part Deux] - Setup AppFuse/jBPM in Eclipse, model defintions using the Jbpm Process Designer.\\
__Part III:__ [Integrating jBPM into AppFuse Part Trois] - Enhance defintions to support tasks, users, schedule and injecting spring beans into actions (Under Construction).\\
At line 5 changed 1 line.
This tutorial is a continuation from [Integrating jBPM into AppFuse]. Please refer to the previous tutorial to complete your basic configuration. In this tutorial we will expand into writing real-world like process defintions, overview of the various jBPM services (persistence, schedule, logging etc) and injecting spring beans into actions. We will also address the issue of redeploying process defintions across server restarts.
This is the 2nd tutorial of a 3 part series. The tutorial covers how to setup AppFuse/Jbpm in Eclipse and model definitions using the Jbpm Process Designer. Before proceeding further please have your basic configuration setup from Part I.\\
At line 9 changed 1 line.
* [2] Create and deploy a simple Process Defintion
* [2] Create a simple Process Defintion
At line 11 changed 7 lines.
* [4] Create and load identities into jBPM database
* [5] Enhance Process Defintion by creating and assigning tasks
* [6] Write test case to validate Process Definition execution
* [7] Enhance Process Defintion by creating ActionHandlers (DecisionHandler)
* [8] Write test case to validate new Process Definition execution
* [9] Wire spring beans inside jBPM Actions
* [10] Test spring bean execution
* [4] Apply patch to prevent process definition redployment across server restart
At line 21 changed 1 line.
This assumes that Appfuse is already configured in Eclipse. [AppFuseEclipse]\\
See [AppFuseEclipse] on how to configure AppFuse with Eclipse.\\
At line 25 changed 2 lines.
!![#2] Create and deploy a simple Process Defintion
Before we dive into creating process definitions with the new tool lets create some the packages where we will save our process defintions and actions.
!![#2] Create a simple Process Defintion
Before creating process definitions lets create a package where we will save our process defintions.
At line 28 changed 3 lines.
Create the following packages:
{{org.appfuse.jbpm.process}}
{{org.appfuse.jbpm.action}}
Create the following package:\\
{{org.appfuse.jbpm.process}}\\
\\
All the processes will live under the {{.process}} package. Whenever you create a new defintion, the process designer creates a new package with that name.
\\
Start off by creating a simple test process.\\
\\
i) Create a new process definition file.\\
At line 32 changed 1 line.
All the processes will live under the {{.process}} package, however, you need to create a new package for each new process definition.
[newdef1.jpg]
At line 34 changed 3 lines.
So lets start off by creating a simple test process.
Create a new package {{org.appfuse.jbpm.process.test}}
Create a new xml file
[newdef2.jpg]
At line 38 changed 1 line.
!What is AppFuse?
ii) Give the process a name - test.\\
At line 40 changed 1 line.
<a href="http://appfuse.org"><img src="https://appfuse.dev.java.net/images/icon.gif" alt="AppFuse Logo" style="margin: 0px 10px 10px 0px; float: left" /></a><a href="http://www.frappr.com/appfuse"><img src="http://www.frappr.com/i/frapper_sticker.gif" style="float: right; margin: 0px 5px 10px 10px" alt="Check out our Frappr!" title="Check out our Frappr!"></a>
[newdef3.jpg]
[newdef4.jpg]
Reference the definition in {{org/appfuse/jbpm/dao/hibernate/applicationContext-hibernate.xml}}:\\
{{{
<!-- jBPM Configuration -->
<bean id="jbpmConfig" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
<!-- pass in existing sessionFactory -->
<property name="sessionFactory" ref="jbpmSessionFactory"/>
<property name="configuration" value="org/appfuse/jbpm/jbpm.cfg.xml"/>
<property name="processDefinitions">
<list>
<ref local="testProcess"/>
</list>
</property>
<property name="createSchema" value="false"/>
</bean>
<bean id="testProcess" class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean">
<property name="definitionLocation" value="org/appfuse/jbpm/process/test/processdefinition.xml"/>
</bean>
}}}
1) Click on one of each process states(Start, State, End) on the left panel and draw them in.
2) Choose transition from the left panel and click thru all the states to establish flow.
[testpackage.jpg]
Congratulations you have written your 1st process defintion!
!![#3] Write test case to validate Process Definition execution
There is a test case in the [previous article|IntegratingJBPMIntoAppFuse]. Create {{ProcessTest.java}} class under {{test/dao/org/appfuse/jbpm/dao}} and copy the code from the previous installment with the following modifications:\\
{{{
protected void onSetUpBeforeTransaction() throws Exception {
...
definition = context.getGraphSession().findLatestProcessDefinition("test");
}
public void testProcessDefinition() throws Exception {
ProcessDefinition def = context.getGraphSession().findLatestProcessDefinition("test");
assertNotNull("Definition should not be null", def);
}
public void testTransitions() throws Exception {
.....
assertEquals("Instance is in 'helloWorld' state", inst.getRootToken().getNode().getName(), "helloWorld");
.....
}
}}}
Recompile and run JUnit test. Execute __ant refresh__.
\\
\\
[test1.jpg]
\\
\\
Select the project's context menu by right clicking on the project root(jbpmtutorial) and choosing the refresh option.
\\
\\
[test2.jpg]
\\
\\
Select Project from the Eclispe's menu above and choose clean.
\\
\\
[test3.jpg]
\\
\\
Now you can run the ProcessTest. Ensure ProcessTest is open and selected and then choose Run As -> JUnit Test
\\
\\
[test4.jpg]
\\
\\
Upon execution JbpmConfiguration will deploy the 'test' process definition, and run through the tests.
[test5.jpg]
\\
\\
Congratulations you have deployed and tested a process defintion!
!![#4] Apply patch to prevent process definition redployment across server restart
;:%%(color: blue)''For production usage it is not ideal to redeploy process definitions on server restarts. Once you have stable definitions there is no need for redeployment. You can apply the following patch to have the JbpmConfiguration not deploy process definitions on restarts, instead have it redeployed only if the definition on the file system is out of sync with the database.''%%
\\
Modify the jbpmConfig bean in {{{org/appfuse/jbpm/dao/hibernate/applicationContext-hibernate.xml}}} to reflect the new overwritten {{ CustomLocalJbpmConfigurationFactoryBean }}.\\
{{{
<!-- jBPM Configuration -->
<bean id="jbpmConfig" class="org.appfuse.jbpm.config.CustomLocalJbpmConfigurationFactoryBean">
....
....
}}}
\\
Create the following package:\\
{{ org.appfuse.jbpm.config }}
\\
\\
Create {{ CustomLocalJbpmConfigurationFactoryBean.java }} in above package and copy code from [CustomLocalJbpmConfigurationFactoryBean.java] into it.\\
Voila! When you restart the server the process defintion wont be redeployed.

Back to IntegratingJBPMIntoAppFusePartDeux, or to the Page History.