A <emphasis>task listener</emphasis> supports following attributes:
<itemizedlist>
<listitem>
<para>
<emphasisrole="bold">event</emphasis> (required): the type of task event on which the task listener will
be invoked. Possible values are <emphasisrole="bold">'create'</emphasis> (occurs when the task
has been created an all task properties are set), <emphasisrole="bold">'assignment'</emphasis>
(occurs when the task is assigned to somebody) or <emphasisrole="bold">'complete'</emphasis>
(occurs when the task is completed and just before the task is deleted from the runtime data).
</para>
</listitem>
<listitem>
<para>
<emphasisrole="bold">class</emphasis>: the delegation class that must be called.
This class must implement the <literal>org.activiti.engine.impl.pvm.delegate.TaskListener</literal>
interface.
<programlisting>
public class MyTaskCreateListener implements TaskListener {
public void notify(DelegateTask delegateTask) {
// Custom logic goes here
}
}</programlisting>
It is also possible to use <linklinkend="serviceTaskFieldInjection">field injection</link> to pass
process variables or the execution to the delegation class.
Note that an instance of the delegation class is created upon process deployment
(as is the case with any class delegation in Activiti), which means that the
instance is shared between all process instance executions.
</para>
</listitem>
<listitem>
<para>
<emphasisrole="bold">expression</emphasis>: (cannot be used together with the <emphasis>class</emphasis> attribute):
specifies an expression that will be executed when the event happens.
<programlisting><activiti:taskListener event="create" expression="${execution.setVariable('myVar', 'Hello from the task listener!')}" /></programlisting>