cancel
Showing results for 
Search instead for 
Did you mean: 

inject custom mail activity behaviours

mathabd
Champ in-the-making
Champ in-the-making
HI,
I want to extend from "MailActivityBehavior" by adding
"Disposition-Notification-To", "Return-Receipt-To".

how I can do that, please ?
thanks
Appreciate your time.
5 REPLIES 5

mathabd
Champ in-the-making
Champ in-the-making
for more precision i use activiti 5.18

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

there are many possibilities:
e.g:
  1. clone activiti project from github
  2. extend org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior
  3. build your own activiti packages/create pull request
the second option:
create your own service task to send an email.

regards
Martin

mathabd
Champ in-the-making
Champ in-the-making
Hi Martin,
Thx for your response, but i want do like shown in this link https://beautifulbytes.wordpress.com/2011/12/18/activiti-use-custom-bpmn-parse-listener-to-inject-cu...
but the internal org.activiti.engine.impl.bpmn.parser.BpmnParseListener interface and related classes have been removed.


regards

jbarrez
Star Contributor
Star Contributor
The BpmnParseListeners have been long ago renamed to BpmnParseHandler. See http://activiti.org/userguide/index.html#_hooking_into_process_parsing

mathabd
Champ in-the-making
Champ in-the-making
Super is don  my solution is:
<pre>
public class CustomBpmnParseHandler extends ServiceTaskParseHandler {

private ExpressionManager expressionManager;

protected void executeParse(BpmnParse bpmnParse, ServiceTask serviceTask) {

 
  super.executeParse(bpmnParse, serviceTask);
  this.expressionManager = bpmnParse.getExpressionManager();
  ActivityImpl activity = findActivity(bpmnParse, serviceTask.getId());
  if (activity.getActivityBehavior() instanceof MailActivityBehavior) {
   activity.setActivityBehavior(
     createCustomMailActivityBehavior(serviceTask.getId(), serviceTask.getFieldExtensions()));
  }
}

public CustomMailActivityBehavior createCustomMailActivityBehavior(String taskId, List<FieldExtension> fields) {
  List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fields);
  return (CustomMailActivityBehavior) ClassDelegate.instantiateDelegate(CustomMailActivityBehavior.class,
    fieldDeclarations);
}

public List<FieldDeclaration> createFieldDeclarations(List<FieldExtension> fieldList) {
  List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>();

  for (FieldExtension fieldExtension : fieldList) {
   FieldDeclaration fieldDeclaration = null;
   if (StringUtils.isNotEmpty(fieldExtension.getExpression())) {
    fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(),
      this.expressionManager.createExpression(fieldExtension.getExpression()));
   } else {
    fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(),
      new FixedValue(fieldExtension.getStringValue()));
   }

   fieldDeclarations.add(fieldDeclaration);
  }
  return fieldDeclarations;
}

}
</pre>

thank you very much.