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


This is version 21. It is not the current version, and thus it cannot be edited.
[Back to current version]   [Restore this version]


Part II: Integrating jBPM into AppFuse - Part Deux - A HowTo for enhancing jBPM Support into AppFuse.

About this tutorial

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.

Table of Contents

  • [1] Install Process Design Tool for Eclispe
  • [2] Create a simple Process Defintion
  • [3] Write test case to validate Process Definition execution
  • [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

[#1] Install Process Design Tool for Eclispe

See AppFuseEclipse on how to configure AppFuse with Eclipse.
Download JBoss jBPM Process Designer Plugin. Version 3.0.13 is used for this tutorial. Copy the features and plugins directory from the unzipped file to your %ECLIPSE_HOME% directory. Start Eclipse from command line by issuing eclipse -clean. Voila!

[#2] Create a simple Process Defintion

Before we dive into creating process definitions with the new tool lets create some packages where we will save our process defintions and actions.

Create the following packages:
org.appfuse.jbpm.process - will contain process defintions
org.appfuse.jbpm.action - will contain jbpm actions
org.appfuse.jbpm.ant - will contain ant tasks (such as loading identities, cleaning schema, etc)

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.
So lets start off by creating a simple test process.

i) Create a new process definition file.

newdef1.jpg

newdef2.jpg

ii) Give the process a name - test.

newdef3.jpg

iii) That should give you the graphical tool interface as such.

newdef4.jpg

We are now ready to start designing!

Before we really begin we have to 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. You can edit the names of the states by clicking on thier name.

2) Choose transition from the left panel and click once on the start state and then on helloWorld state. Then from helloWorld to end.

testpackage.jpg

Congratulations you have created a process definition using the process design tool!

Let's write a test case to validate our process definition.

[#2] Write test case to validate Process Definition execution

We have already written a test case in the previous article, So go ahead and 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");
        .....
  }

It time to recompile and run our 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

And finally select Project from the Eclispe's menu above and choose clean. test3.jpg

Now you can run the ProcessTest. Ensure you have ProcessTest 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

You have successfully deployed and tested a process definition.


Attachments:
newdef3.jpg Info on newdef3.jpg 23693 bytes
CustomLocalJbpmConfigurationFactoryBean.java Info on CustomLocalJbpmConfigurationFactoryBean.java 5625 bytes
test3.jpg Info on test3.jpg 11009 bytes
newdef2.jpg Info on newdef2.jpg 30770 bytes
test2.jpg Info on test2.jpg 32009 bytes
newdef4.jpg Info on newdef4.jpg 60839 bytes
newdef1.jpg Info on newdef1.jpg 50306 bytes
test5.jpg Info on test5.jpg 164921 bytes
test4.jpg Info on test4.jpg 84699 bytes
testpackage.jpg Info on testpackage.jpg 78539 bytes
test1.jpg Info on test1.jpg 107150 bytes


Go to top   More info...   Attach file...
This particular version was published on 02-Mar-2007 18:08:16 MST by AmeerAhmed.