Autowiring services in a custom TaskListener for Activiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2012 10:15 AM
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
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2012 04:12 PM
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2012 05:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2012 06:17 PM
https://forums.alfresco.com/en/viewtopic.php?f=34&t=42982
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2012 06:53 AM
It is somewhat related but that forum does not provide a proper solution to the problem mentioned here.
Some of the other discussion forums mention that Activiti standalone does not use the Spring Application context due to which Dependency Injection is not available when customizing its code, there is a way to modify the process engine configuration of Activiti which allows it to work under the Spring context, but I am not sure how and what modification is required here after Activiti has been integrated inside Alfresco.
Please let me know if you have idea about whether the above is true or not.
Regards,
Varun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2012 04:45 PM
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2012 02:18 AM
- I see you defining property values, but you say in your title "Autowiring". AFAIK, auto wiring won't work in alfresco context
- How do you connect the existing context (alfresco) with your test-context?
- What is the exact error? BeanNotFoundExceptions or are the beans just NULL?
- How do you "hook" in your task listener into the activiti-engine? Using the BPMNParseListener? Or using activiti:delegateExpression?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2012 03:29 AM
>>>>I basically meant Dependency Injection over here using the property values defined in the spring beans xml
How do you connect the existing context (alfresco) with your test-context?
>>>>>No special handling has been done for this except for running this as a web extension in Alfresco
What is the exact error? BeanNotFoundExceptions or are the beans just NULL?
>>>>>The properties of the TestTaskListener class do not get initialized which I expect should have been injected using the spring beans xml specified above
How do you "hook" in your task listener into the activiti-engine? Using the BPMNParseListener? Or using activiti:delegateExpression?
>>>>>
<userTask ………………>
<extensionElements>
<activiti:taskListener event="create"
class="com.dsny.task.listeners.TestTaskListener2"></activiti:taskListener>
</extensionElements>
</userTask>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2014 05:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 07:47 AM