cancel
Showing results for 
Search instead for 
Did you mean: 

how to override ServiceTaskDelegateExpressionActivityBehavio

workflowuser2
Champ in-the-making
Champ in-the-making
Hi

I need to override ServiceTaskDelegateExpressionActivityBehavior:

public class CustomServiceTaskDelegateExpressionActivityBehavior extends ServiceTaskDelegateExpressionActivityBehavior {

public CustomServiceTaskDelegateExpressionActivityBehavior(Expression expression) {
       super(expression);
}
public void execute(ActivityExecution execution) throws Exception {

  // i need to change classloading behavior here.
  /
}

}

As mentioned above, I just want to change behavior of execute method and keep rest of the behavior.

What's the best way to do this?

I tried hooking up new behavior class using custom pre parser listener:

public class CustomParserListener implements BpmnParserListener {

public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {

       if (activity.getActivityBehavior() instanceof ServiceTaskDelegateExpressionActivityBehavior) {
           // QUESTION: How to create CustomServiceTaskDelegateExpressionActivityBehavior object from activity.getActivityBehavior()?
                //e.g. activity.setActivityBehavior(new CustomServiceTaskDelegateExpressionActivityBehavior (????));
                // ServiceTaskDelegateExpressionActivityBehavior members do not have getter methods (e.g no getExpression())
       }
     }
}

Forgive me for asking trivial question, if it is.

Activiti Newbie
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
Since the expression field is protected and has no accessor, you won't get in out in the normal way. I can think of 3 solutions, depending on what you're trying to reach:
  • Instead of overriding the class, try leveraging the ExpressionManagers resolvers. You can add an additional ELResolver in the chain of resolver, which will be called when an expression is evaluated. If the object requested is one you need "special" classloading for, do your fancy magic in the ELResolver and return it. The delegate will just be called as usual.

  • Use reflection to extract field from delegateBehavior (*fishy*)

  • Use custom activiti-version, modifying the BPMNParse

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
My first question would be: why?

workflowuser2
Champ in-the-making
Champ in-the-making
My first question would be: why?

Hi Ronald,

I am trying some changes in the classloaders as mentioned in the following post:
http://forums.activiti.org/en/viewtopic.php?f=4&t=1433&start=0

The above might be helpful in solving an issue I have:

http://forums.activiti.org/en/viewtopic.php?f=6&t=4259

Activiti newbie