Event Listener Plugin#

Plugin Descriptor interface:

EventListenerPluginDescriptor

An EventListener Plugin can listen to Server Events .

This allows creating powerful functionality when integrating with external systems.

For a list of all Server Events, refer to the Event class documentation and all its subtypes.

Implementing an EventListener#

The Event Listener Plugin may provide one or more EventListener implementations.

Simple example of an EventListener implementation:

public final class ExampleEventListener implements EventListener<AccountCreatedScimEvent>
{
    private final ExampleConfiguration _config;

    public ExampleEventListener(ExampleConfiguration config)
    {
        _config = config;
    }

    @Override
    public Class<AccountCreatedScimEvent> getEventType()
    {
        return AccountCreatedScimEvent.class;
    }

    @Override
    public boolean isSynchronous()
    {
        // return true if it is ok to run the handle method asynchronously
        // (cannot fail the request if async)
        return false;
    }

    @Override
    public void handle(AccountCreatedScimEvent event)
    {
        // react to the event
    }

    @Override
    default void close() throws IOException
    {
        // cleanup resources
    }
}

Notice that the EventListener itself declares which Event type it wants to handle.

It is possible to listen for Event directly, in which case an EventListener will receive all Event types.

Was this helpful?