Interface CachingDataProvider
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 TypeMethodDescriptionvoidCallback that informs the DataProvider that an earlier requested subject has now been discarded.voidCallback that informs theCachingDataProviderthat a new request has been received and it should start sending data.default voidsetPublisher(CachingPublisher cachingPublisher) Sets a publisher for theCachingDataProviderto use when publishing data.
-
Method Details
-
setPublisher
Sets a publisher for theCachingDataProviderto use when publishing data.This setter should be implemented when the
CachingDataProvideris 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- TheCachingPublisherfor thisCachingDataProviderto use when publishing data.
-
onRequest
Callback that informs theCachingDataProviderthat a new request has been received and it should start sending data.The
CachingDataProvidershould 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
CachingDataProvidershould 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.
-