cancel
Showing results for 
Search instead for 
Did you mean: 

Are there hooks within activiti engine?

markusfaeth
Champ in-the-making
Champ in-the-making
Hello, I would like to do something like this: For every user task you create call my custom method (1).

Actually I could write additional code in our logic at two points to almost accomplish this: After creating a new process instance, look if the execution was stopped by a user task. And after completing a user task, do the same. But this only works from within our logic, so timer started process instances won't be handled by this (2).

So, are there hooks to do something like (1), or is there a general way to handle the special case of timer started process instances (2)?

Thank you!
3 REPLIES 3

gant
Champ in-the-making
Champ in-the-making
Hi,

You can use TaskListeners http://activiti.org/userguide/#taskListeners. I would use this, if you want to control (define) at design time of the process model, what code should be executed at runtime.

If it's always the same code, that shoud be run, you could have a look at pre- and post parse listeners. You'll find information on them in this forum.

Regards,
michael

markusfaeth
Champ in-the-making
Champ in-the-making
Thank you!  Smiley Very Happy

This sounds promising, i'll check that!  :geek:

markusfaeth
Champ in-the-making
Champ in-the-making
BpmnParseListeners are perfect for this purpose. Thanks again!  Smiley Very Happy

Here is some of the code for all others who want to do this:


public class ParseListener implements BpmnParseListener {
public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
  UserTaskActivityBehavior utab = (UserTaskActivityBehavior)activity.getActivityBehavior();
  utab.getTaskDefinition().addTaskListener("create", new CommonUserTaskCreateListener());
}
// other method implementations, all empty…
}

CommonUserTaskCreateListener is actually creating messages (portal internal message system) for portal users getting informed that a new task is available…