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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(ExceptionListener listener) Adds the supplied listener to this dispatcher.void
errorOccurred
(Object source, SQLException exception) Notify about a SQLExceptionvoid
errorOccurred
(SQLException exception) boolean
iterator()
void
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
-
-
Method Details
-
errorOccurred
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
-
addListener
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
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
- Specified by:
iterator
in interfaceIterable<ExceptionListener>
-