Event Listener module
Job module
Language module
Macro Module
Servlet Filter module
Servlet module
Theme module
Web UI modules
Workflow module

Annotation based Event Listener with component module


Confluence 3.3 and later


DEPRECATED in favor of Event Listener with Atlassian Spring Scanner.

You can register your listener as component inside atlassian-plugin.xml.

<atlassian-plugin key="listenerExample" name="Listener Examples" plugins-version="2">
        <vendor name="${project.organization.name}" url="${project.organization.url}" />

    <component name="Annotated Event Listener" class="com.atlassian.confluence.plugin.example.listener.AnnotatedListener" key="annotatedListener"/>


The methods must be annotated with the com.atlassian.event.api.EventListener annotation and only take a single parameter of the type of event this method is to service.

The event listener must also register itself with the EventPublisher which can be injected into the constructor. The event listener will need to implement the DisposableBean interface to unregister itself when the plugin is disabled or uninstalled.

package com.atlassian.confluence.plugin.example.listener;

import com.atlassian.confluence.event.events.security.LoginEvent;
import com.atlassian.confluence.event.events.security.LogoutEvent;
import com.atlassian.event.api.EventListener;
import com.atlassian.event.api.EventPublisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;

public class AnnotatedListener implements DisposableBean{
    private static final Logger log = LoggerFactory.getLogger(AnnotatedListener.class);

    protected EventPublisher eventPublisher;

    public AnnotatedListener(EventPublisher eventPublisher) {
        this.eventPublisher = eventPublisher;

    public void loginEvent(LoginEvent event) {
        log.error("Login Event: " + event);

    public void logoutEvent(LogoutEvent event) {
        log.error("Logout Event: " + event);

    // Unregister the listener if the plugin is uninstalled or disabled.
    public void destroy() throws Exception

INFO: An annotation-based event listener does not need to implement the com.atlassian.event.EventListener class.

Rate this page: