Module org.firebirdsql.jaybird
Package org.firebirdsql.gds.ng.listeners

# Class ExceptionListenerDispatcher

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

All Implemented Interfaces:
  `Iterable<ExceptionListener>`, `ExceptionListener`

public final class ExceptionListenerDispatcher extends Object implements 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
Constructor
Description
`ExceptionListenerDispatcher(Object source)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addListener(ExceptionListener listener)`
Adds the supplied listener to this dispatcher.
`void`
`errorOccurred(Object source, SQLException exception)`
Notify about a SQLException
`void`
`errorOccurred(SQLException exception)`
`boolean`
`isShutdown()`
`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 Details

### ExceptionListenerDispatcher

public ExceptionListenerDispatcher(Object source)

## Method Details

### errorOccurred

public void errorOccurred(Object source, 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(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 Iterator<ExceptionListener> iterator()

Specified by:
  `iterator` in interface `Iterable<ExceptionListener>`