我创建了邮件任务配置
<serviceTask id="mailtask_name" name="Name" flowable:delegateExpression="${STCustomMail}" flowable:type="mail" >
<extensionElements>
<flowable:field name="to">
<flowable:string><![CDATA[[email protected]]]></flowable:string>
</flowable:field>
<flowable:field name="subject">
<flowable:string><![CDATA[Subject]]></flowable:string>
</flowable:field>
<flowable:field name="text">
<flowable:string><![CDATA[Text]]></flowable:string>
</flowable:field>
</extensionElements>
</serviceTask>
和班级:
@Log
@Service
public class STCustomMail implements JavaDelegate {
private Expression subject;
private Expression to;
private Expression text;
public void execute(DelegateExecution execution) {
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
String subjectText = "New subject";
execution.setVariable(subject.getValue(execution).toString(), subjectText);
execution.setVariable(to.getValue(execution).toString(), "[email protected]");
execution.setVariable(text.getValue(execution).toString(), "newtext");
}
}
不幸的是,我的STCustomMail类无法正常工作。我无法修改任何邮件数据。
怎么了?
也许有另一种解决方案如何配置/创建动态(?)邮件数据位置?
flowable:delegateExpression
和flowable:type
不能混在一起。
默认情况下,当flowable:type
为mail
时,Flowable将使用MailActivityBehavior
执行电子邮件的发送。这意味着你的JavaDelegate
永远不会被调用。
如果要更改邮件活动行为,则需要为其提供自己的实现。为了做到这一点,你需要提供自己的ActivityBehaviorFactory
(你可以扩展DefaultActivityBehaviorFactory
)并覆盖以下方法:
MailActivityBehavior createMailActivityBehavior(ServiceTask serviceTask)
MailActivityBehavior createMailActivityBehavior(SendTask sendTask)