Interface CachingDataProvider
Interface that must be implemented in order to provide data updates to DataSource peers for cached objects. It contains callbacks that handle subscription and discard requests.
Note: the CachingDataProvider
methods are not called on a dedicated worker thread.
Therefore, if any of these methods are likely take a relatively long time to execute, they should
be coded to run in a separate thread.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Callback that informs the DataProvider that an earlier requested subject has now been discarded.void
Callback that informs theCachingDataProvider
that a new request has been received and it should start sending data.default void
setPublisher
(CachingPublisher cachingPublisher) Sets a publisher for theCachingDataProvider
to use when publishing data.
-
Method Details
-
setPublisher
Sets a publisher for the
CachingDataProvider
to use when publishing data.This setter should be implemented when the
CachingDataProvider
is defined as an anonymous inner class in order to make the publisher accessible within theonRequest(String)
andonDiscard(String)
methods.Example:
CachingPublisher publisher = dataSource.createCachingPublisher( new PrefixNamespace("/CCYS/"), new CachingDataProvider() { CachingPublisher cachingPublisher;
- Parameters:
cachingPublisher
- TheCachingPublisher
for thisCachingDataProvider
to use when publishing data.
-
onRequest
Callback that informs the
CachingDataProvider
that a new request has been received and it should start sending data.The
CachingDataProvider
should perform the following tasks when this method is called:- If that DataSource is not already subscribed to the back end system that supplies the data for this subject, the DataSource should make a subscription for the subject.
- When data is received from the back end system for the subject, the
CachingDataProvider
should callCachingPublisher.publish(com.caplin.datasource.messaging.Message)
to publish the current image of the data.
- Parameters:
subject
- The subject for this request.
-
onDiscard
Callback that informs the DataProvider that an earlier requested subject has now been discarded.
- Parameters:
subject
- The subject that has been discarded.
-