AnsweredAssumed Answered

Autowiring services in a custom TaskListener for Activiti

Question asked by varun33 on Jul 30, 2012
Latest reply on Jul 6, 2017 by Aleksey Bykov
Hello Friends,

I created a new customized TaskListener for an Activiti workflow and am trying to access the various Alfresco Services within it like the WorkflowService, NodeService, RuntimeService using the Spring autowire functionality but it is not working.

Please find mentioned below the code written by me and let me know the corrections that I need to make in order to make this work.


{{{
<!–TestTaskListener .java–>
public class TestTaskListener implements TaskListener {
       WorkflowService workflowService;
   NodeService nodeService;
         TransactionService transactionService;
   RuntimeService runtimService;

   @Override
   public void notify(DelegateTask delegateTask) {
               if (null == nodeService) {
         System.out.println("Inside notify - Varun - null");
      } else {
         System.out.println("Inside notify - Varun - NOT null");
      }
   }
}

<!–test-context.xml–>
<bean id="testListener" class="com.ds.task.listeners.TestTaskListener">
      <property name="workflowService" ref="WorkflowService" />
      <property name="nodeService" ref="NodeService" />
      <property name="runtimService" ref="activitiRuntimeService" />
      <property name="transactionService">
         <ref bean="transactionService" />
      </property>
   </bean>
}}}


Thanks,
Varun

Outcomes