![]() | The content on this page is deprecated. Please see the separate documentation space for developer reference material about FishEye and Crucible. |
An event listener plugin module is an object which is notified when certain internal Crucible or FishEye events occur.
To include an event listener module add a listener
element to your atlassian-plugins.xml
file:
<listener key="example-listener" class="com.atlassian.crucible.example.plugin.spring.ExampleListener"/>
and create a class which implements com.atlassian.event.EventListener
. See the FishEye event and Crucible event javadoc for specific event types. See the javadoc for EventListener to understand the general details regarding events.
For example, if we want to listen for all events, and print a message to standard output we would write:
public class ExampleListener implements EventListener { public void handleEvent(Event event) { System.out.println("Got event: " + event); } public Class[] getHandledEventClasses() { return new Class[0]; } }
Event listeners may implement StateAware
if they need to be notified when the module is enabled or disabled.
A plugin containing an event listener module needs to declare a dependency on atlassian-events
in its pom.xml
:
<dependency> <groupId>com.atlassian.event</groupId> <artifactId>atlassian-event</artifactId> <version>0.5</version> <scope>provided</scope> </dependency>
Note that this is a provided
dependency – the plugin does not need to include the atlassian-events
classes.