Executing Custom Execution Listener During Transition of Sequence Flow

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member II

Executing Custom Execution Listener During Transition of Sequence Flow

Jump to solution

   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.

1 Solution

Accepted Solutions
Highlighted
Intermediate

Re: Executing Custom Execution Listener During Transition of Sequence Flow

Jump 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‌

View solution in original post

1 Reply
Highlighted
Intermediate

Re: Executing Custom Execution Listener During Transition of Sequence Flow

Jump 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‌

View solution in original post