05-17-2018 06:30 AM
05-17-2018 10:23 AM
Thanks both of you..
Finally the issue is solved by passing the listener in delegate expression instead of class .
<activiti:taskListener event="all" delegateExpression="${TestClass}"></activiti:taskListener>
05-17-2018 07:52 AM
TaskListeners that are set in 'class' attribute are created/instantiated by the engine so Spring autowiring will not work.
<activiti:taskListener event="complete" class="example.MyTaskListener">
05-17-2018 08:35 AM
Hi Bassam,
Thanks for your prompt response.
Here is my code. any changes to be done for this.
public class TestClass implements TaskListener {
@Autowired
private HistoryService historyService;
public void notify(DelegateTask delegateTask) {
String currentEvent = delegateTask.getEventName();
if("delete".equalsIgnoreCase(currentEvent))
return;
try {
System.out.println(historyService);// it returns null, please let us know the workaround
}
}
XML File :
<activiti:taskListener event="all" class="com.callback.TestClass"></activiti:taskListener>
05-17-2018 08:38 AM
this is spring boot application. anything specific for springboot ??
05-17-2018 09:41 AM
You can try registering your task listener as a spring bean (i.e. using @Component) and use an expression to call it.
<activiti:taskListener event="all" expression="${myTaskListener.notify(execution)}" />
By the way, it could be any class (spring bean) doesn't have to implement TaskListener.
05-17-2018 08:20 AM
Hi,
As Bassam Al-Sarori mentioned task listeners are basically bind in context of task and workflow so it should be set in your workflow tasks, not separated wired as a spring bean .
Regards,
Rupesh
05-17-2018 08:36 AM
Hi Rupesh,
Thanks for your prompt response.
We are using SPRING BOOT .
Here is my code. any changes to be done for this.
public class TestClass implements TaskListener {
@Autowired
private HistoryService historyService;
public void notify(DelegateTask delegateTask) {
String currentEvent = delegateTask.getEventName();
if("delete".equalsIgnoreCase(currentEvent))
return;
try {
System.out.println(historyService);// it returns null, please let us know the workaround
}
}
XML File :
<activiti:taskListener event="all" class="com.callback.TestClass"></activiti:taskListener>
05-17-2018 08:58 AM
Hi,
Here i think you may have to depends-on attribute on task listener class the way it is added in following bean definition.
<bean id="abc" class="com.test.ABC" parent="baseJavaDelegate" depends-on="activitiBeanRegistry"
abstract="true">
I think this will help you.
Regards,
Rupesh Sawaliya
EnProwess Technologies
05-17-2018 10:23 AM
Thanks both of you..
Finally the issue is solved by passing the listener in delegate expression instead of class .
<activiti:taskListener event="all" delegateExpression="${TestClass}"></activiti:taskListener>
Explore our Alfresco products with the links below. Use labels to filter content by product module.