Crowd 2.1 and later
On this page:
If you are familiar with writing a listener for Confluence, writing a listener plugin for Crowd should be almost identical.
In Crowd, events are thrown for almost all operations that occur to a user. (If you need more or find a spot we haven't thought of, please let us know!.)
The following example is contained in event-listener-example.zip plugin project.
The Listener Plugin Module
Below is an example
atlassian-plugin.xml that will configure your event listeners:
The Event Listener Class
Any Java class can be made an event listener by using the
com.atlassian.event.api.EventListener annotation. This can be achieved by implementing a public method with one parameter, which is the event to be handled, and annotating the method with
com.atlassian.event.api.EventListener annotation. A class can contain multiple event listener methods.
The following example event listener listens for user creation events and prints out the display name of each newly created user:
Refactoring Old (Before Crowd 2.1) Event Listeners to Annotation-Based Event Listeners
Old event listeners can be refactored to use annotations by following these steps:
implements EventListenerfrom the class signature.
getHandledEventClasses()method from the class.
- Change the type of
- In case the listener is interested in all events, annotate
- In other cases, create new public method for each of the handled events taking a parameter which has the same type as the handled event. Then add
com.atlassian.event.api.EventListenerannotation to each new method and make them delegate to
Events and Event Types
Generally Crowd uses the following naming scheme for events:
This event would indicate that a User (<Object>) has been updated (<Operation>).
Limitations of Events
Please take note of the following limitations:
- Events are a notification that something has occurred. The event system is not designed to allow a listener to veto the action that caused the event.
- There is no loop detection. If you write a listener for the
GroupUpdatedEventthat itself causes a
GroupUpdatedEventto be generated, you are responsible for preventing the ensuing infinite loop.