# ApplicationEventListener<E extends ApplicationEvent> class abstract interface

A listener for a specific type of ApplicationEvent.

Implementations of this interface receive strongly typed application events during the lifecycle of the application, such as context refresh, shutdown, or domain-specific triggers.

This is a typed variant of EventListener and is automatically detected by the JetLeaf event dispatch system when registered in the application context.

### Key Features:

- Type Safety: Strongly typed event handling with generic parameter
- Automatic Detection: Automatically registered when defined as a pod
- Lifecycle Integration: Receives events during application lifecycle
- Synchronous Dispatch: Events are typically dispatched synchronously

### Event Types:

Common application events include:

- `ApplicationStartedEvent` - Application context has been refreshed
- `ApplicationStoppedEvent` - Application context is being stopped
- `ApplicationFailedEvent` - Application context failed to refresh
- `CustomDomainEvent` - Application-specific domain events

### Registration:

Listeners are automatically detected and registered when they are:

- Defined as pods in the application context
- Implement the ApplicationEventListener interface
- Specify the exact event type they wish to receive

### Example Usage:

    class DatabaseReadyListener implements ApplicationListener<DatabaseReadyEvent> {
      @override
      void onApplicationEvent(DatabaseReadyEvent event) {
        print('Database connection established: ${event.connectionId}');
        // Perform initialization that requires database access
      }
    }

### Multiple Event Types:

To listen for multiple event types, implement multiple interfaces:

    class MultiEventListener implements
        ApplicationEventListener<ApplicationStartedEvent>,
        ApplicationEventListener<ApplicationStoppedEvent> {

      @override
      void onApplicationEvent(ApplicationStartedEvent event) {
        print('Application started');
      }

      @override
      void onApplicationEvent(ApplicationStoppedEvent event) {
        print('Application stopped');
      }

      // Note: Dart doesn't support method overloading by return type,
      // so you'll need to use different method names or type checking
    }

### Ordering and Priority:

Listeners can implement Ordered or PriorityOrdered to control the order in which they receive events:

    class HighPriorityListener implements
        ApplicationEventListener<CustomEvent>,
        Ordered {

      @override
      void onApplicationEvent(CustomEvent event) {
        // Handle event
      }

      @override
      int getOrder() => Ordered.HIGHEST_PRECEDENCE;
    }

### Error Handling:

Exceptions thrown in event listeners are caught and logged by the event publisher but do not prevent other listeners from receiving the event.

### Thread Safety:

Typically, listeners are invoked synchronously on the same thread that publishes the event. Ensure thread-safe operations if events can be published from multiple threads.

See also:

- ApplicationEvent for the base event class
- `ApplicationEventPublisher` for event publication
- EventListener for the non-typed variant
- `SmartApplicationListener` for conditional event handling

Annotations
  - @Generic(ApplicationEventListener)

## Properties

hashCode → int
  The hash code for this object.
  no setter inherited
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited

## Methods

noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
onApplicationEvent(E event) → void
  Handle an application event of type `E`.
supportsEventOf(ApplicationEvent event) → bool
  Returns true if the listener supports the given event.
toString() → String
  A string representation of this object.
  inherited

## Operators

operator ==(Object other) → bool
  The equality operator.
  inherited