Friday, June 12, 2009

Understanding workflow languages

Using JBPM as a starting point and taking a look at its documentation, I’ve realized that it’s not really that hard to build a very simple Workflow Model. It basically consists of the following classes.

Node: Each Step in the workflow flow is defined by a node. A node is a Command object (Command Design Pattern) and has references to the incoming transitions and to the outgoing transitions.

Transition: A directional link that links two nodes together.

Execution: An execution is the context that the workflow is currently working on. An execution has a reference to the node it is at the moment. Transitions pass this context from node to node.

So the workflow basically works this way.

An Execution object is instantiated with a reference to the first node. From that point on, the execution of the flow is controlled by events passed to the Execution Object.
In general, Nodes are responsible for sending events to the Execution Object, determining what the execution of the process will do next.

So this is a very simple example of a workflow Model implementation. In Pseudo.

Class XNode implements Node{
Public execute(Execution exe){
doSomething…..
exe.event(“transicionA”)
}
}
Class Execution{
Node currentNode;
Public event(Event e){
currentNode.getTransitionForEvent(e).take(this)
}
}
Class Transition{
Node origin;
Node destination;
Public take(Execution e){
destination.execute(e)
}
}

No comments: