org.glassfish.jersey.server.monitoring

## Interface ApplicationEventListener

    @Contract
     @ConstrainedTo(value=SERVER)
    public interface ApplicationEventListener

Jersey specific provider that listens to `application events`. The implementation of this interface will be called for two kind of events: application events and `request events`. This interface will listen to all `application event types` but only to first request event which is the `RequestEvent.Type.START`. On this event the application event listener can decide whether it will listen to the request and return `request event listener` for listening to further request events. }

The implementation of this interface can be registered as a standard Jersey/JAX-RS provider by annotating with `@Provider` annotation in the case of class path scanning, by registering as a provider using `ResourceConfig` or by returning from `Application.getClasses()` or `Application.getSingletons()`}. The provider can be registered only on the server side.

Application event listener can read data of events but must not modify them in any way. The implementation must be thread safe (the methods might be called from different threads).

Author:
  Miroslav Fuksa

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `onEvent(ApplicationEvent event)` Process the application `event`.
`RequestEventListener` `onRequest(RequestEvent requestEvent)` Process a new request and return a `request event listener` if listening to `request events` is required.

### Method Detail

#### onEvent

    void onEvent(ApplicationEvent event)

Process the application `event`. This method is called when new event occurs.

Parameters:
  `event` - Application event.

#### onRequest

    RequestEventListener onRequest(RequestEvent requestEvent)

Process a new request and return a `request event listener` if listening to `request events` is required. The method is called once for each new incoming request. If listening to the request is required then request event must be returned from the method. Such a request event listener will receive all request events that one request. If listening to request event for the request is not required then `null` must be returned from the method (do not return empty mock listener in these cases as it will have negative performance impact).

Parameters:
  `requestEvent` - Event of type `RequestEvent.Type.START`.
Returns:
  Request event listener that will monitor the events of the request connected with `requestEvent`; null otherwise.