I extended SequenceFlowParseHandler for setting executionListener to sequence flow. By doing so I am able to execute my custom listener everytime a transition happens in the workflow.
ActivitiListener activitiListener = new ActivitiListener();
activitiListener.setEvent(ExecutionListener.EVENTNAME_START);
activitiListener.setImplementation("${customExecutionListener}");
activitiListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
I am using delegate Expression for implementation type but class fails to autowire beans in my customExecutionListener I dont know where i'm going wrong.
Solved! Go to Solution.
Likely this is because your listener is running on a servlet thread that is not part of the spring application context.
One option is to use an application Context provider:
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;public class ApplicationContextProvider implements ApplicationContextAware{
private static ApplicationContext context;
public static ApplicationContext getApplicationContext() {
return context;
}
@Override public void setApplicationContext(ApplicationContext ac) throws BeansException {
context = ac;
}
}
This way you can retrieve the Spring application context and then the bean you need.
Greg
bp3
Likely this is because your listener is running on a servlet thread that is not part of the spring application context.
One option is to use an application Context provider:
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;public class ApplicationContextProvider implements ApplicationContextAware{
private static ApplicationContext context;
public static ApplicationContext getApplicationContext() {
return context;
}
@Override public void setApplicationContext(ApplicationContext ac) throws BeansException {
context = ac;
}
}
This way you can retrieve the Spring application context and then the bean you need.
Greg
bp3
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.