On 6/20/06, Florent Robineau <[EMAIL PROTECTED]> wrote:
Hi,
I've been trying to use the beanflow component to build a workflow, but
I seem not to be able to get it right. My goal is to use the beanflow
component to register a state (and then persist it into a database) and
to allow to do transitions between states (based on permissions granted
to the user, but this is another matter). So, so far I do not need my
workflow to change steps by itself since each change of state should be
triggered by an external event.
OK
BTW it'd be nice to have an example test program where the workflow is
implemented using JPA (EJB 3 persistence).
I took a look at the Javadoc, the source code and the examples, but I
did not understand where to put the business code. According to the doc,
I guess I'm supposed to write my own workflow, which subclasses the
class Workflow<T>, parametrizing it with an enum which holds the
different states my workflow can be in. Then the transitions between the
different states would be managed by additional methods I would write
myself.
Yes.
Though:
- if my enum is <startStep, middleStep, endStep>, what use is there for
the methods startStep(), middleStep() and endStep()? Are they
automatically called by the introspector when the state of the workflow
changes?
Yes. So the idea is there are N steps available to be executed. When &
how states are transitioned can be defined by external events or by
the workflow itself (such as for loops & joins and so forth).
So the general idea is to have a Java method for each step which
executes the business logic; then the enum represents the current step
you are on. (You can just use a String for the method name if you
prefer).
- what is the difference between "return Step.myNextStep" and
"setNextStep(myNextStep)" ?
There's no big difference; they do the same really. The main
difference is coupling; e.g. one day we could have a regular POJO
which just understands the enum and doesn't derive from Workflow being
the business logic.
- could anyone provide me with a basic example which actually does
something like what I'm looking for, or even a hint to the solution?
The test cases are the best place to look; there's various workflows
available. The only thing missing really is an example which loads the
workflow instance from a database using JPA then persists it again.
http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-beanflow/src/test/java/org/apache/servicemix/beanflow/
--
James
-------
http://radio.weblogs.com/0112098/