I want to use my company email infrastructure.So I created a class and extent MailActivityBehavior and override execute(DelegateExecution execution). How should I force the engine to use my implementation?
Thanks for your time.
I want to use my company email infrastructure.So I created a class and extent MailActivityBehavior and override execute(DelegateExecution execution). How should I force the engine to use my implementation?
Thanks for your time.
@Component
public class MyMailSending implements JavaDelegate {
@Autowired
private MailService mailService;
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
mailService.doSomething();
}
}
<serviceTask id="serviceTask" flowable:delegateExpression="${myMailSending}"></serviceTask>
This uses a service task to deal with mail sending, instead of provided mail task.
Thank you. I prefer a general solution for different behaviors on flowable.
Dear @joram
could you please help me and answer my question?
Hey
You need 3 things
1)Override the factory
@Service
public class XYActivitiBehaviorFactory extends DefaultActivityBehaviorFactory
{
protected MailActivityBehavior createMailActivityBehavior(String taskId, List fields)
{
List fieldDeclarations = createFieldDeclarations(fields);
return (MailActivityBehavior)ClassDelegate.defaultInstantiateDelegate(XYMailActivityBehavior.class, fieldDeclarations);
}
}
2)Extend MailActivityBehavior and add custom logic
public class XYMailActivityBehavior extends MailActivityBehavior
{
protected void addTo(Email email, String to, String tenantId)
{
.
}
}
3)Register your factory in processengineconfiguration.
@Autowired
private XYActivitiBehaviorFactory _factory;
processEngineConfiguration.setActivityBehaviorFactory(_factory);