Package org.firebirdsql.gds.ng.listeners

## Class ExceptionListenerDispatcher

- java.lang.Object
- - org.firebirdsql.gds.ng.listeners.ExceptionListenerDispatcher

All Implemented Interfaces:
  `java.lang.Iterable<ExceptionListener>`, `ExceptionListener`

    public final class ExceptionListenerDispatcher
    extends java.lang.Object
    implements java.lang.Iterable<ExceptionListener>, ExceptionListener

Listener dispatcher for `ExceptionListener`.

This implementation uses `WeakReference` (or more specifically `WeakHashMap`. Therefor listeners without a strong reference may be removed an no longer notified at any time.

Since:
  3.0
Author:
  Mark Rotteveel

### Constructor Summary

Constructors
`ExceptionListenerDispatcher​(java.lang.Object source)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addListener​(ExceptionListener listener)` Adds the supplied listener to this dispatcher.
`void` `errorOccurred​(java.lang.Object source, java.sql.SQLException exception)` Notify about a SQLException
`void` `errorOccurred​(java.sql.SQLException exception)`
`boolean` `isShutdown()`
`java.util.Iterator<ExceptionListener>` `iterator()`
`void` `removeAllListeners()` Removes all listeners from this dispatcher.
`void` `removeListener​(ExceptionListener listener)` Removes the supplied listener from this dispatcher.
`void` `shutdown()` Shuts down this dispatcher and removes all listeners.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Constructor Detail

#### ExceptionListenerDispatcher

    public ExceptionListenerDispatcher​(java.lang.Object source)

### Method Detail

#### errorOccurred

    public void errorOccurred​(java.lang.Object source,
                              java.sql.SQLException exception)

Description copied from interface: `ExceptionListener`
Notify about a SQLException

Specified by:
  `errorOccurred` in interface `ExceptionListener`
Parameters:
  `source` - The source of the event; note for caller: this should be the object this listener is registered at.
  `exception` - error that occurred.

#### errorOccurred

    public void errorOccurred​(java.sql.SQLException exception)

#### addListener

    public void addListener​(ExceptionListener listener)

Adds the supplied listener to this dispatcher.

A call to this method has no effect after `shutdown()` has been called.

Parameters:
  `listener` - Listener object

#### removeListener

    public void removeListener​(ExceptionListener listener)

Removes the supplied listener from this dispatcher.

Parameters:
  `listener` - Listener object

#### removeAllListeners

    public void removeAllListeners()

Removes all listeners from this dispatcher.

#### shutdown

    public void shutdown()

Shuts down this dispatcher and removes all listeners.

After shutdown calls to `addListener(ExceptionListener)` are ignored.

#### isShutdown

    public boolean isShutdown()

Returns:
  `true` when this dispatcher has been shut down.

#### iterator

    public java.util.Iterator<ExceptionListener> iterator()

Specified by:
  `iterator` in interface `java.lang.Iterable<ExceptionListener>`