Activiti and Spring

I am currently starting to work myself into Alfresco Activiti, which is, by the way a great process engine that you can use from and in liferay.

The following problem might occur to you if you are working with Spring and Activiti:

You can use the activiti designer in eclipse to connect several steps in your activiti process to one process chain like "unzip files", "inpect unzipped files" and "copy inspected files to fileserver".

To do so, you can either use the simplest approach: Specify a Java Class (extending JavaDelegate) for your Service Task, connect all tasks by a Sequence Flow and let activiti do the calling. In this way you have access to the DelegateExecution object that lets you (for example) share variables across your process.

This will work, and every class will get called, but your spring configuration will be totally ignored.

If you decide to work with the "Expression" type, you need to define your Task in your Spring config and then you have all the spring injection magic that you like. But how do you get the DelegateExecution object in it?

I found out that "execution" is a reserved word in activiti and if you want to have an expression that just calls the standard execution(DelegateExecution execution) method, you can do it simply like this:


This is how it will look like in your Eclipse Designer:

Eclipse Designer: Adding Expression

That´s all: You have your Spring injection AND you have the DelegateExecution object.

If you got interested and you are thinking about taking a look into Activiti (it´s free by the way!), you can do so here: http://activiti.org/

If you like this post it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.