How to force flowable engine to use my implementation

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.

public class MyMailSending implements JavaDelegate {
    private MailService mailService;

    public void execute(DelegateExecution delegateExecution) throws Exception {

<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?


You need 3 things

1)Override the factory
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.

private XYActivitiBehaviorFactory _factory;