Class AbstractEventStream
java.lang.Object
com.suse.salt.netapi.event.AbstractEventStream
- All Implemented Interfaces:
EventStream, AutoCloseable
- Direct Known Subclasses:
WebSocketEventStream
Implements basic listener bookkeeping for EventStream.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<EventListener> Listeners that are notified of a new events. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListener(EventListener listener) Adds a listener.protected voidclearListeners(int code, String phrase) Removes all listeners.intHelper method that returns the current number of subscribed listeners.protected voidnotifyListeners(Event event) Notifies all listeners of an eventvoidremoveEventListener(EventListener listener) Removes a listener.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EventStream
close, isEventStreamClosed
-
Field Details
-
listeners
Listeners that are notified of a new events.
-
-
Constructor Details
-
AbstractEventStream
public AbstractEventStream()
-
-
Method Details
-
addEventListener
Adds a listener.- Specified by:
addEventListenerin interfaceEventStream- Parameters:
listener- Reference to the class that implementsEventListener.
-
removeEventListener
Removes a listener.- Specified by:
removeEventListenerin interfaceEventStream- Parameters:
listener- Reference to the class that implementsEventListener.
-
getListenerCount
public int getListenerCount()Helper method that returns the current number of subscribed listeners.- Specified by:
getListenerCountin interfaceEventStream- Returns:
- The current number listeners.
-
notifyListeners
Notifies all listeners of an event- Parameters:
event- the event
-
clearListeners
Removes all listeners.- Parameters:
code- an integer code to represent the reason for closingphrase- a String representation of code
-