|
Bring order to the workplace
Continued from page: 3
Wednesday, February 22, 2006
Enhydra Shark
An Open Source workflow engine that can be deployed in diverse
workflow implementations
Enhydra Shark is an Open Source workflow engine written in
Java. The engine can be deployed to various types of workflow implementations.
You can use it in a CORBA-based implementation, as a server side engine for a
web based workflow, as it provides libraries for implementing JSP clients or if
you are designing a Swing based implementation for your workflow, you can
integrate the engine in your Java Swing Application. The engine uses XPDL (XML
Process Definition Language) by WfMC for defining the workflow processes. It can
be used in Workflows for both SMBs and Enterprises.
For installation, it requires Java to be pre-installed on
the system and can be installed as a CORBA service. The installation is simple,
as the only configuration it requires is to choose one option from the available
set. We chose the option for installing without any services.
Shark can be configured with most database servers
available by un-commenting the database connection string of your choice in
Shark's configuration file.
Let's deploy
We will look into deploying a sample workflow application implemented
in Java. The process is for reimbursement of travel expenses to an employee. The
process outline is that an employee sends a claim to the manager who in turn can
approve or reject it. If approved, the claim is forwarded to the account manager
for reimbursing it.
Create a package
First create a process definition, which has to be a standard XPDL
schema. We used Enhydra JaWE to create the same.
A Windows executable for its installer can be downloaded
for free from the URL http://forge.objectweb.org/projects/jawe.
Run the application after installation and create a new
package by clicking File>New. By default the package is named “newpkg”.
To edit properties for the package, right click on it from the navigator window
on left and click Properties from the menu. In the package dialog that opens,
change the Id field to “trv_exp_reim_pcq”, Name field to “TravelClaim”
and choose Non-Blocked for graph conformance drop down list. Also under the
Script heading, populate Type field with “text/java”.
You can also edit additional information such as version,
author name, etc from the Redefinable Tab on the same dialog box. Save the
changes by clicking on the 'tick mark' on top left of the dialog and close
it.
 |
| The XPDL schema of our sample workflow process, created using Enhydra JaWE |
Create a process
Create process by clicking on the processes button on the toolbar.
Right click on process from Navigator and again choose properties. In General
Tab populate name with “Travel ClaimReimburseProcess” and choose public
access level from the Access Level drop down list. Our process involves
communication between three types of roles, Employee, Manager and Accounts
Manager. To create these three as participants go to the participants tab and
click on new button, edit its name to Employee. Similarly add participants
Accounts Manager and Manager. We need two process variables cliam_amount of type
Integer and initial value zero, and Boolean variable Approve with initial value
false. Go to the Workflow Variables and add these variables by clicking on new
button on the variables tab and editing specified properties from the dialog box
that opens.
After defining the participants and variables, click on the
Activity tab to add a workflow activity called send_claim. Here choose the
performer as Employee, Start Mode as Manual, and the Finish Mode as Automatic
from the respective drop down lists. Go to the Extended Attribute tab, populate
the name field with “Variable ToProcess_UPDATE” and the value field with
claim_amount. Similarly create activity process_claim, whose performer is
Manager, start mode is automatic, finish mode is manual, and the extended
attribute attribute name is “Variable ToProcess_UPDATE” with value Approve.
We now need to define “Transitions” from one workflow
activity to another. Go to the Transitions Tab and click on new button. Populate
the name field with “toTransport”, choose source as send_claim in the From
drop down list and approve_claim from the To drop down list. Similarly define a
transition “toReimburse” from source approve claim to destination
reimburse_claim, here provide condition “approve = = true”.
This completes our modeling of the process. Save the XPDL
schema to the disk and exit JaWE.
Application to implement
activities
Create three java classes SendClaimAgent for activity send_claim,
ProcessAgent for activity process_claim and ReimburseClaimAgent for activity
reimburse_claim. Since Shark provides a JavaClassToolAgent for implementing
ToolAgents in Java, all these three claases are to be inherited from this class.
For this you need to include the following three jar files in the \lib
folder to your system classpath: sharkinternalapi.jar; sharkcommonapi.jar and
sharkclientapi.jar. After
implementing these classes we are all ready to run our sample process in Enhydra
Shark.
Running the process
Open shark.conf from \conf folder to configure
shark to include the path where the Java Classes have been defined by editing
ToolAgentPluginDir to the folder where these java classes are present. Save and
close Shark.conf file. Start shark admin by executing runA.bat from \bin
folder.
Go to the "Package management" section, press
"Load", select "test-JavaScript.xpdl" and press
"Load". Then double-click on the XPDL schema from its saved location.
Wait while shark loads the package into memory, and press "Exit". Then
go to User Management to add users. Populate User Group with “EmployeeGroup“,
user name with emp, password as emp and provide arbitrary name and last name.
Similarly create a user of EmployeeGroup for Transport Manager. To map these
users to roles in the schema click on Mapping Tab under User Management, click
on Employee on Left Pane, and user emp on right pane and then click on Apply
Button. Similarly map role Transports Manager to the other user created.
To map the activities to Applications from the
"Application mapping" section, press "Add" button. In the
left panel Select "send_claim", and in the right panel select "org.enhydra.shark.toolagent.JavaClassToolAgent". Populate
"Application name" field in the right pane with "SendClaimAgent".
Finally, press the "Apply" button. Similarly Map the activities
process_claim and reimburse_claim to respective java classes.
Now that everything is prepared for the process execution,
you can return to the "Process instantiation management" and press
"Instantiate" button when you select "TravelClaimReimburseProcess"
.
Execute runWH.bat from sharks bin directory, login as
employee choose emp from the User drop down list. You will see the emp worklist
item for send_claim appearing. Double click on the row or click on the check box
for the entry and click on complete button. Click yes when asked to update
process variables and enter the reimburse claim amount in the dialog box that
opens and click on OK.
Now login as Transport Manager from another instance of
worklist handler appliocation and similarly finish the activity process_claim by
updating process variable Approve to true. Switch back to Admin application and
go the Worklist Handler Section , choose the worklist item and click on complete
to complete the sample workflow process.
This was a very simple process to explain you the procedure
for implementing a workflow solution in Enhydra Shark. You can implement more
complex processes by provifding more appropriate schemas and Java Class
implementations for activities. Page(s) 1 2 3 4
|