AnsweredAssumed Answered

Proper way to implement a custom a taskListener in Activiti?

Question asked by jpotts Moderator on Feb 8, 2012
Latest reply on Mar 25, 2015 by divakar
I want to implement a custom taskListener that leverages the ActionService. I have written a Java class that implements TaskListener. The problem I'm having is how to properly inject the dependency and how to refer to the taskListener from the process definition.

I tried creating the following in one of my context files:
<bean id="externalReviewNotification" class="com.someco.bpm.ExternalReviewNotification">
        <property name="actionService">
            <ref bean="ActionService" />
        </property>
</bean>

I've also tried a version that includes "parent="baseJavaDelegate"".

I then refer to the bean from my process using delegateExpression, like this:
<activiti:taskListener event="create" delegateExpression="${externalReviewNotification}"></activiti:taskListener>

That fails with a org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Unknown property used in expression

I think it is because my bean isn't registered with the activiti bean registry, but I'm not sure.

I've tried using a class attribute instead of the delegateExpression attribute. In that case, notify is called, but my dependencies aren't loaded since it isn't using the bean.

I looked at the source to see how the JavaScript taskListener works. It has a getServiceRegistry method. I suppose I could implement that, but I'm wondering if there's a better way?

Jeff

Outcomes