cancel
Showing results for 
Search instead for 
Did you mean: 

Service Task Class Definition with Spring

frauke
Champ in-the-making
Champ in-the-making
Hello everybody,

is it possible to inject the JavaDelegate class MyServiceTask with Spring?
I would like to pass some properties and would like to keep that out of the process definition.

<serviceTask id="myService" name="My Service Task" activiti:class="de.vps.test.process.MyServiceTask"/>
Frauke
3 REPLIES 3

frauke
Champ in-the-making
Champ in-the-making
Ok, I saw the example in the User Guide, but I am still not sure how to use it with the DelegateExecution parameter, which I need to get the variables for instance.

activiti:expression="#{printer.printMessage()}
Frauke

jbarrez
Star Contributor
Star Contributor
There are a few ways to do it:

activiti:expression="${printer.printMessage(execution)}", where printer is a Spring bean.

the printMessage method must then look like this: public void printMessage(DelegateExecution execution).

An other way to do it, is using a delegateExpression:

<bean id="myJavaDelegate" class="org…"> , which implements JavaDelegate.

And then do this: activiti:delegateExpression="${myJavaDelegate}"

frauke
Champ in-the-making
Champ in-the-making
Great, thats perfect.
Thanks a lot!

Frauke