Package adams.core
Class PublishSubscribeHandler
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.PublishSubscribeHandler
-
- All Implemented Interfaces:
LoggingSupporter
,SizeOfHandler
,Serializable
public class PublishSubscribeHandler extends LoggingObject
Manages publishing of data to subscribed listeners.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description int
m_NumPublished
the number data items published.Set<PublicationListener>
m_Subscribers
the subscribers.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description PublishSubscribeHandler()
Initializes the handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSubscriber(PublicationListener s)
Adds the subscriber.void
clear()
Removes all subscribers.int
getNumPublished()
Returns the number of data items published.protected void
initialize()
Initializes the members.void
publish(Object source, Object data)
Publishes the data.void
removeSubscriber(PublicationListener s)
Removes the subscriber.int
size()
Returns the number of subscribers.String
toString()
Returns some info on the pubsub handler.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Subscribers
public Set<PublicationListener> m_Subscribers
the subscribers.
-
m_NumPublished
public int m_NumPublished
the number data items published.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.
-
addSubscriber
public void addSubscriber(PublicationListener s)
Adds the subscriber.- Parameters:
s
- the subscriber to add
-
removeSubscriber
public void removeSubscriber(PublicationListener s)
Removes the subscriber.- Parameters:
s
- the subscriber to remove
-
clear
public void clear()
Removes all subscribers.
-
size
public int size()
Returns the number of subscribers.- Returns:
- the subscribers
-
getNumPublished
public int getNumPublished()
Returns the number of data items published.- Returns:
- number of published items
-
publish
public void publish(Object source, Object data)
Publishes the data.- Parameters:
source
- the source that generated the datadata
- the data to publish
-
-