Customization > Creating Custom Listeners
Creating Custom Listeners
To create custom listeners, perform the following steps:
1. Create a Java class for the custom listener with the annotation CustomEventListener.
2. Define methods for processing each event that you want to handle in your custom listener. Add the annotation Event to these methods. The eventObject parameter in the method is the event object that is dispatched.
A method can be used to process one or more events.
A listener class must not contain more than one method listening to the same event.
Example of using separate methods for processing each event:
@CustomEventListener
public class WTPartCustomListener {
@ Event(eventClass=WorkInProgressServiceEvent.class,
eventKey=WorkInProgressServiceEvent.PRE_CHECKIN
public void processWTPartPreCheckinEvent1(Object eventObject) throws Exception {
}
@ Event(eventClass=WorkInProgressServiceEvent.class,
eventKey=WorkInProgressServiceEvent.POST_CHECKOUT)
public void processWTPartPostCheckoutEvent2(Object eventObject) throws Exception {
}
}
Example of using the same method for processing multiple events:
@ Event(eventClass=WorkInProgressServiceEvent.class,
eventKey=WorkInProgressServiceEvent.PRE_CHECKIN)
@ Event(eventClass=WorkInProgressServiceEvent.class,
eventKey=WorkInProgressServiceEvent.POST_CHECKOUT)
public void processWTPartPreCheckinPostCheckoutEvent1(Object eventObject) throws Exception {
}
3. Compile your module using the CCD tool. For more information, see External Targets.
Listener processing order
CustomEventListener classes are registered and processed in ascending order of their class names. If more than one class contains methods listening to the same event, the methods will be executed in the sequence in which they are registered.
Was this helpful?