IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Developing client applications for BPEL processes and tasks > Create plug-ins to customize human task functionality
Create notification event handlers for Business Process Choreographer
Notification events are produced when human tasks are escalated. Business Process Choreographer provides functionality for handling escalations, such as creating escalation work items or sending emails.
You can create notification event handlers to customize the way in which escalations are handled.
To implement notification event handlers, you can implement the NotificationEventHandlerPlugin interface, or you can extend the default com.ibm.task.spi.NotificationEventHandler service provider interface (SPI) implementation class.
Complete the following steps to create a notification event handler.
Procedure
- Write a class that implements the NotificationEventHandlerPlugin interface or extends the NotificationEventHandler implementation class. This class can invoke the methods of other classes.
If you use the NotificationEventHandlerPlugin interface, you must implement all of the interface methods. If you extend the SPI implementation class, overwrite the methods that you need.
This class runs in the context of a Javaâ„¢ Platform, Enterprise Edition ( Java EE) Enterprise application. Ensure that this class and its helper classes follow the EJB specification.
The plug-in is invoked with the authority of the EscalationUser role. This role is defined when the human task container is configured.
If you want to call the HumanTaskManagerService interface from this class, do not call a method that updates the task that produced the event. This action might result in inconsistent task data in the database.
- Assemble the plug-in class and its helper classes into a JAR file.
You can make the JAR file available in one of the following ways:
- As a utility JAR file in the application EAR file.
- As a shared library that is installed with the application EAR file.
- As a shared library that is installed with the TaskContainer application. In this case, the plug-in is available for all tasks.
- Assemble the plug-in class and its helper classes into a JAR file.
If the helper classes are used by several Java EE applications, you can package these classes in a separate JAR file that you register as a shared library.
- Create a service provider configuration file for the plug-in in the META-INF/services/ directory of your JAR file.
The configuration file provides the mechanism for identifying and loading the plug-in. This file conforms to the Java EE service provider interface specification.
- Create a file with the name com.ibm.task.spi. plug-in_nameNotificationEventHandlerPlugin, where plug-in_name is the name of the plug-in.
For example, if your plug-in is called HelpDeskRequest (event handler name) and it implements the com.ibm.task.spi.NotificationEventHandlerPlugin interface, the name of the configuration file is com.ibm.task.spi.HelpDeskRequestNotificationEventHandlerPlugin.
- In the first line of the file that is neither a comment line (a line that starts with a number sign (#)) nor a blank line, specify the fully qualified name of the plug-in class created in step 1.
For example, if your plug-in class is called MyEventHandler and it is in the com.customer.plugins package, then the first line of the configuration file must contain the following entry: com.customer.plugins.MyEventHandler.
Results
You have an installable JAR file that contains a plug-in that handles notification events and a service provider configuration file that can be used to load the plug-in. You can register API event handlers with a task instance, a task template, or an application component.If s: You only have one eventHandlerName property available to register both API event handlers and notification event handlers. If you want to use both an API event handler and a notification event handler, the plug-in implementations must have the same name, for example, Customer as the event handler name for the SPI implementation.
You can implement both plug-ins using a single class, or two separate classes. In both cases, you need to create two files in the META-INF/services/ directory of your JAR file, for example, com.ibm.task.spi.CustomerNotificationEventHandlerPlugin and com.ibm.task.spi.CustomerAPIEventHandlerPlugin.
Package the plug-in implementation and the helper classes in a single JAR file.
To make a change to an implementation effective, replace the JAR file in the shared library and restart the server. If the plug-in is part of the application EAR file, it is sufficient to reinstall the updated application.
What to do next
You now need to install and register the plug-in so that it is available to the human task container at run time. You can register notification event handlers with a task instance, a task template, or an application component.
Create plug-ins to customize human task functionality
Related tasks:
Installing API event handler and notification event handler plug-ins for human tasks
Registering API event handler and notification event handler plug-ins with task templates, task models, and tasks
Related information:
Enterprise JavaBeans specification
Java 2 service provider interface specification