Class BaseSubscriptionListener
- java.lang.Object
-
- com.caplin.datasource.subscription.BaseSubscriptionListener
-
- All Implemented Interfaces:
SubscriptionListener
public class BaseSubscriptionListener extends java.lang.Object implements SubscriptionListener
A base implementation of
SubscriptionListener
that can be used to easily provideSubscriptionListener
implementations without the need to override every method. This class can be extended in order to override only the methods a particularSubscription
is interested in as an alternative to implementing every method inSubscriptionListener
.It is highly recommended that you extend this class rather than directly implementing the
SubscriptionListener
interface as this class will log warnings if callbacks occur upon methods you have not overridden. This is preferable to the simple empty implementations of an 'adapter' class where unexpected callbacks upon methods you have not overridden can go unnoticed and are difficult to trace.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.logging.Logger
logger
Provides protected access to the logger that was passed to the constructor.
-
Constructor Summary
Constructors Constructor Description BaseSubscriptionListener(java.util.logging.Logger logger)
Creates aBaseSubscriptionListener
that uses the providedLogger
to log warnings about callbacks made on methods that have not been overridden.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
containerUpdated(Subscription subscription, Peer peer, ContainerMessage containerMessage)
Called when a container update is received.void
genericMessageUpdated(Subscription subscription, Peer peer, GenericMessage message)
Called when an update to generic message data is received.void
jsonUpdated(Subscription subscription, Peer peer, JsonMessage message)
Called when an update to json message data is received.void
newsUpdated(Subscription subscription, Peer peer, NewsMessage newsMessage)
Called when a news headline update is received.void
pageUpdated(Subscription subscription, Peer peer, PageMessage pageMessage)
Called when a page update is received.void
permissionUpdated(Subscription subscription, Peer peer, PermissionMessage permissionMessage)
Called when when a permission update is received.void
recordType2Updated(Subscription subscription, Peer peer, RecordType2Message recordType2Message)
Called when an update to type 2 data in a record is received.void
recordType3Updated(Subscription subscription, Peer peer, RecordType3Message recordType3Message)
Called when an update to type 3 data in a record is received.void
recordUpdated(Subscription subscription, Peer peer, RecordMessage recordMessage)
Called when an update to type 1 data in a record is received.void
storyUpdated(Subscription subscription, Peer peer, StoryMessage storyMessage)
Called when a story update is received.void
subjectErrorReceived(Subscription subscription, Peer peer, SubjectErrorEvent subjectErrorEvent)
Called when there is an error in a subscription.void
subjectStatusReceived(Subscription subscription, Peer peer, SubjectStatusEvent subjectStatusEvent)
Called when there is a change in the status of a subscription.
-
-
-
Constructor Detail
-
BaseSubscriptionListener
public BaseSubscriptionListener(java.util.logging.Logger logger)
Creates aBaseSubscriptionListener
that uses the providedLogger
to log warnings about callbacks made on methods that have not been overridden.- Parameters:
logger
- TheLogger
that warning messages are logged to.
-
-
Method Detail
-
containerUpdated
public void containerUpdated(Subscription subscription, Peer peer, ContainerMessage containerMessage)
Description copied from interface:SubscriptionListener
Called when a container update is received.
- Specified by:
containerUpdated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.containerMessage
- The container update.The operations on the
ContainerMessage
are not normalized; therefore the message may contain contradictory operations, for example an add for an element followed by a delete for the same element.
-
newsUpdated
public void newsUpdated(Subscription subscription, Peer peer, NewsMessage newsMessage)
Description copied from interface:SubscriptionListener
Called when a news headline update is received.
- Specified by:
newsUpdated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.newsMessage
- The news update.
-
pageUpdated
public void pageUpdated(Subscription subscription, Peer peer, PageMessage pageMessage)
Description copied from interface:SubscriptionListener
Called when a page update is received.
- Specified by:
pageUpdated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.pageMessage
- The page update.
-
permissionUpdated
public void permissionUpdated(Subscription subscription, Peer peer, PermissionMessage permissionMessage)
Description copied from interface:SubscriptionListener
Called when when a permission update is received.
- Specified by:
permissionUpdated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.permissionMessage
- The permission update.
-
recordType2Updated
public void recordType2Updated(Subscription subscription, Peer peer, RecordType2Message recordType2Message)
Description copied from interface:SubscriptionListener
Called when an update to type 2 data in a record is received.
- Specified by:
recordType2Updated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.recordType2Message
- The record update.
-
recordType3Updated
public void recordType3Updated(Subscription subscription, Peer peer, RecordType3Message recordType3Message)
Description copied from interface:SubscriptionListener
Called when an update to type 3 data in a record is received.
- Specified by:
recordType3Updated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.recordType3Message
- The record update.
-
recordUpdated
public void recordUpdated(Subscription subscription, Peer peer, RecordMessage recordMessage)
Description copied from interface:SubscriptionListener
Called when an update to type 1 data in a record is received.
- Specified by:
recordUpdated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.recordMessage
- The record update.
-
storyUpdated
public void storyUpdated(Subscription subscription, Peer peer, StoryMessage storyMessage)
Description copied from interface:SubscriptionListener
Called when a story update is received.
- Specified by:
storyUpdated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.storyMessage
- The story update.
-
subjectErrorReceived
public void subjectErrorReceived(Subscription subscription, Peer peer, SubjectErrorEvent subjectErrorEvent)
Description copied from interface:SubscriptionListener
Called when there is an error in a subscription.
- Specified by:
subjectErrorReceived
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the error occurred.peer
- The DataSource peer that sent this subscription error.subjectErrorEvent
- The subscription error.
-
subjectStatusReceived
public void subjectStatusReceived(Subscription subscription, Peer peer, SubjectStatusEvent subjectStatusEvent)
Description copied from interface:SubscriptionListener
Called when there is a change in the status of a subscription.
- Specified by:
subjectStatusReceived
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the status change occurred.peer
- The DataSource peer that sent this change in subscription status.subjectStatusEvent
- The subscription status event.
-
genericMessageUpdated
public void genericMessageUpdated(Subscription subscription, Peer peer, GenericMessage message)
Description copied from interface:SubscriptionListener
Called when an update to generic message data is received.
- Specified by:
genericMessageUpdated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.message
- The record update.
-
jsonUpdated
public void jsonUpdated(Subscription subscription, Peer peer, JsonMessage message)
Description copied from interface:SubscriptionListener
Called when an update to json message data is received.
- Specified by:
jsonUpdated
in interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.peer
- The DataSource peer supplying the update.message
- The json update.
-
-