The Activiti API provides extension points that can be used as custom implementations that you can trigger where necessary. Task listener is one such extension point.
A task listener can be used when you need to trigger a custom implementation upon the occurrence of a particular task.
To create a task listener you need to write a java class that implements the
org.activiti.engine.delegate.TaskListener interface. In the java class, you need to add the listener logic inside the notify method as follows:
For example, if you want to log the time that a task starts, you can use a logger inside the task listener to print the start time of a task.
Once you write the Java class, you can build the project containing the class, add the built
.jar file inside the
<EI_HOME>/lib directory, and restart the server.
In the process definition you can point to the created class using an eventListener as follows:
If you look at the process definition given above, you will see that there is a parameter named event. You can use the event parameter to define the event that should trigger the task listener class.
For more information, see Task Listener in the Activiti User Guide.
For information on other event listeners that allow you to handle various events from business processes you create, see Event handlers in the Activiti User Guide.