Package com.suse.salt.netapi.event
Class AbstractEventStream
- java.lang.Object
-
- com.suse.salt.netapi.event.AbstractEventStream
-
- All Implemented Interfaces:
EventStream
,AutoCloseable
- Direct Known Subclasses:
WebSocketEventStream
public abstract class AbstractEventStream extends Object implements EventStream
Implements basic listener bookkeeping for EventStream.
-
-
Constructor Summary
Constructors Constructor Description AbstractEventStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEventListener(EventListener listener)
Adds a listener.protected void
clearListeners(int code, String phrase)
Removes all listeners.int
getListenerCount()
Helper method that returns the current number of subscribed listeners.protected void
notifyListeners(Event event)
Notifies all listeners of an eventvoid
removeEventListener(EventListener listener)
Removes a listener.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.suse.salt.netapi.event.EventStream
close, isEventStreamClosed
-
-
-
-
Method Detail
-
addEventListener
public void addEventListener(EventListener listener)
Adds a listener.- Specified by:
addEventListener
in interfaceEventStream
- Parameters:
listener
- Reference to the class that implementsEventListener
.
-
removeEventListener
public void removeEventListener(EventListener listener)
Removes a listener.- Specified by:
removeEventListener
in 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:
getListenerCount
in interfaceEventStream
- Returns:
- The current number listeners.
-
notifyListeners
protected void notifyListeners(Event event)
Notifies all listeners of an event- Parameters:
event
- the event
-
clearListeners
protected void clearListeners(int code, String phrase)
Removes all listeners.- Parameters:
code
- an integer code to represent the reason for closingphrase
- a String representation of code
-
-