cancel
Showing results for 
Search instead for 
Did you mean: 

How to Autowire Spring Bean in JavaDelegate

dmoss18
Champ in-the-making
Champ in-the-making
Is it possible to autowire a spring bean in my javadelegate?

If not, is it possible to set a spring bean as a data member in my javadelegate using a delegate expression?

Basically, I need to know if there is any way to call bean methods from a javaDelegate class I have written.  I know I can do it using an expression, but what if I want to call many expressions in many different beans to perform a task?  Can I do it at all from my javaDelegate or do I just have to create many service tasks, each one using a different expression to call a single method?

Thanks
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
If you define your java-delegate in spring, you can wire in as many services/beans as you want. The only difference is they you don't use the "activiti:class" in you're service-task, but rather, you point to the bean in your spring-context that implements JavaDelegate:


<serviceTask id="serviceTask" activiti:delegateExpression="${delegateExpressionBean}" />



<bean id="delegateExpressionBean" class="org.activiti.my.java.Delegate">
      <property name="orderService" value="org.activiti.my.order.Service" />
      …

See user guide for more details.