Activiti is a Workflow Mangement System (WfMS) that is completely written in Java. Activiti is a opensource-project initiated by alfresco. Activiti is based on a Process Virtual Machine (PVM). Simplified the PVM can execute graphs consisting of nodes and transitions. Based on this abstraction several graph-based languages can be implemented. Activiti implements BPMN 2.0 and is therefore one of the first Worflow-Engines that is able to execute BPMN 2.0.

Activiti is very flexible and can be easily extended to fit custom needs. One important customization can be done by creating an ActivityBehavior. ActivityBehaviors reflect the behavior of nodes executed by the PVM. The so called ServiceTask-activity has an attribute in its xml-representation that specifies the behavior of this Activity. It looks like this:

<serviceTask activiti:class="MyImplementation" ... >

The class MyImplementation.class or a jar containing the class have to be in {TOMCAT_HOME}/webapps/activiti-rest/WEB-INF/lib/. During runtime Activiti instantiates this class by reflection. But lets continue on how to implement the MyImplementation class.

The implementation should extend org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior. The activiti-engine executes public void execute(ActivityExecution execution) during runtime so if you want to realize custom behavior you have to override this method. At the end you should call leave(ActivityExecution execution) that tells the Engine that the activity is completed.

Some details on the concept “PVM” can be found here

You will be surprised to read about jBPM while I talked about Activiti above. jBPM 4 is also based on a PVM. The lead-architect of the Activiti-Engine is Tom Baeyens. He was a developer of jBPM before he started the work on Activiti. I think he is the/one father of the PVM-abstraction.

http://docs.jboss.com/jbpm/pvm/article/

 

If you want store variables without custom configuration you can store objects or simple-types of type

  • null
  • String
  • Boolean
  • Short
  • Integer
  • Long
  • Date
  • Double
  • ByteArray
  • Serializeable

For the types String to Double not only the object-types but also the corresponding simple-types (http://download.oracle.com/javase/6/docs/api/javax/management/openmbean/SimpleType.html) are supported. The easiest way to store your custom objects is to make them Serializeable. In most cases you only have to add implements java.util.Serializeable to your class definition. Internally Activiti creates a byte-array (byte[]) out of your object and stores this byte-array. If you retrieve this object you will get an object of type java.lang.Object.

© 2011 Softwareengineering in practise Suffusion theme by Sayontan Sinha