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 forExceptionListener
.This implementation uses
WeakReference
(or more specificallyWeakHashMap
. 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(java.lang.Object source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(ExceptionListener listener)
Adds the supplied listener to this dispatcher.void
errorOccurred(java.lang.Object source, java.sql.SQLException exception)
Notify about a SQLExceptionvoid
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.
-
-
-
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 interfaceExceptionListener
- 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 interfacejava.lang.Iterable<ExceptionListener>
-
-