05-12-2017 01:56 AM
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.
05-12-2017 08:52 AM
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
05-12-2017 08:52 AM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.