JIRA 4.0 : Listeners
This page last changed on Jun 11, 2009 by rosie@atlassian.com.
Listeners are unique to JIRA, and a very powerful way to extend it. JIRA has a complete event subsystem which fires events whenever anything happens inside the application. For example an ISSUE_CREATED event is fired whenever an issue is created. A Listener is a class that implements one of the Listener interfaces. It is then called whenever events occur in JIRA. Using those events, you can then perform any action you want. For example the email sent by JIRA is driven by the MailListener. Listeners are most useful when you want to drive or affect external systems from events which occur within JIRA. On this page: Listener InterfacesThere are currently two different concrete Listeners within JIRA (both of which extend the base JiraListener interface).
Example ListenersThe examples provided may be freely used and modified for use in your own environment. The source of all examples is available and should give you good overview of how simple it is to write your own listeners. Both example listeners are included with JIRA 2.1, and both implement UserEventListener and IssueEventListener.
Other examples of useful tasks that can be accomplished with listeners are:
Registering a ListenerTo register a listener:
Editing Listener PropertiesYou can edit a listeners properties by clicking 'Edit' for that listener in the 'Listeners' section of the 'Administration' tab. Removing a ListenerTo remove a listener, click 'Del' for that listener in the 'Listeners' section of the 'Administration' tab. Custom EventsWith the ability to add custom events to JIRA, the Listener must be updated to deal with the event as appropriate. This is possible by providing an implementation for the method customEvent(IssueEvent event) in the Listener. For example, the MailListener implementation passes the custom event on for notification processing. The DebugListener logs that the custom event has been fired. |
![]() |
Document generated by Confluence on Oct 06, 2009 00:26 |