Hi,
I am currently migrating from activiti 5.20.0 to 6.0.0.Beta2. The project is a spring boot (version: 1.3.5.RELEASE) project with activiti integration.
My goal is to inject a custom task listener via Java. I am facing a problem with my current approach due to an API change in activiti 6.
How I have solved the problem so far:
In activiti 5 a custom task listener is injected by overriding the method DefaultActivityBehaviorFactory::createUserTaskActivityBehavior(UserTask userTask, TaskDefinition taskDefinition) and setting the custom listener to the taskDefinition. The custom DefaultActivityBehaviorFactory replaces the original one in the SpringProcessEngineConfiguration.
Custom DefaultActivityBehaviorFactory:
[java]
@Named
public class MyActivityBehaviorFactory extends DefaultActivityBehaviorFactory {
@Inject
TaskListener userTaskCreatedListener;
@Override
public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask, TaskDefinition taskDefinition) {
taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, userTaskCreatedListener);
return super.createUserTaskActivityBehavior(userTask, taskDefinition);
}
}
[/java]
Register custom DefaultActivityBehaviorFactory:
[java]
@Configuration
public class ActivitiConfiguration {
@Inject
MyActivityBehaviorFactory myActivityBehaviorFactory;
@Bean
public BeanPostProcessor activitiConfigurer() {
return new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
// inject custom behavior into the activiti process engine
// configuration
if (bean instanceof SpringProcessEngineConfiguration) {
((SpringProcessEngineConfiguration) bean).setActivityBehaviorFactory(myActivityBehaviorFactory);
}
return bean;
}
};
}
}
[/java]
In activiti 6 that does not work anymore because the method DefaultActivityBehaviorFactory::createUserTaskActivityBehavior(ExpressionManager expressionManager, UserTask userTask) does not provide the taskDefinition anymore.
A link to a migration guide from activiti 5 to 6 or a hint on how to solve my problem would be appreciated.
Best regards,
Dennie