Package com.ibm.di.server
Class ThreadSafeListenableImpl<ListenerT>
- java.lang.Object
-
- com.ibm.di.server.ThreadSafeListenableImpl<ListenerT>
-
- Type Parameters:
ListenerT- Type of listener.
- All Implemented Interfaces:
Listenable<ListenerT>
public class ThreadSafeListenableImpl<ListenerT> extends java.lang.Object implements Listenable<ListenerT>
This class is for internal use only. Users must not rely on it.
Thread safe container for listeners. Relies on double-dispatch via visitors instead of using event objects.
- Since:
- 7.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceThreadSafeListenableImpl.ThrowingVisitor<ListenerT>Visitor of listeners.static interfaceThreadSafeListenableImpl.Visitor<ListenerT>Visitor of listeners.
-
Constructor Summary
Constructors Constructor Description ThreadSafeListenableImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(ListenerT listener)Register new listener.ListenerTremoveListener(ListenerT listener)Unregister listener.voidvisitListeners(ThreadSafeListenableImpl.ThrowingVisitor<ListenerT> visitor)Visit registered listeners with the specified visitor.voidvisitListeners(ThreadSafeListenableImpl.Visitor<ListenerT> visitor)Visit registered listeners with the specified visitor.
-
-
-
Method Detail
-
addListener
public void addListener(ListenerT listener)
Register new listener.- Specified by:
addListenerin interfaceListenable<ListenerT>- Parameters:
listener- Listener.
-
removeListener
public ListenerT removeListener(ListenerT listener)
Unregister listener. Due to implementation specifics, the listener may get notified a few more times after it is unregistered. It is guaranteed that the listener will not get notified after it is removed, if you have only one notification thread (visitListeners(ThrowingVisitor)is called always by the same thread) and removal happens on that notification thread.- Specified by:
removeListenerin interfaceListenable<ListenerT>- Parameters:
listener- Registered listener.- Returns:
- the actual listener being registered. This is useful when the passed in instance is only used for identification and the actual listener needs to be properly disposed of.
-
visitListeners
public void visitListeners(ThreadSafeListenableImpl.ThrowingVisitor<ListenerT> visitor) throws java.lang.Exception
Visit registered listeners with the specified visitor.- Parameters:
visitor- Visitor.- Throws:
java.lang.Exception- Error thrown by the visitor.
-
visitListeners
public void visitListeners(ThreadSafeListenableImpl.Visitor<ListenerT> visitor)
Visit registered listeners with the specified visitor.- Parameters:
visitor- Visitor.
-
-