Interface CachingDataProvider


  • public 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

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void onDiscard​(java.lang.String subject)
      Callback that informs the DataProvider that an earlier requested subject has now been discarded.
      void onRequest​(java.lang.String subject)
      Callback that informs the CachingDataProvider that a new request has been received and it should start sending data.
      default void setPublisher​(CachingPublisher cachingPublisher)
      Sets a publisher for the CachingDataProvider to use when publishing data.
    • Method Detail

      • setPublisher

        default void setPublisher​(CachingPublisher cachingPublisher)

        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 the onRequest(String) and onDiscard(String) methods.

        Example: CachingPublisher publisher = dataSource.createCachingPublisher( new PrefixNamespace("/CCYS/"), new CachingDataProvider() { CachingPublisher cachingPublisher;

        Parameters:
        cachingPublisher - The CachingPublisher for this CachingDataProvider to use when publishing data.
      • onRequest

        void onRequest​(java.lang.String subject)

        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:

        1. 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.
        2. When data is received from the back end system for the subject, the CachingDataProvider should call CachingPublisher.publish(com.caplin.datasource.messaging.Message) to publish the current image of the data.
        3.  

        Parameters:
        subject - The subject for this request.
      • onDiscard

        void onDiscard​(java.lang.String subject)

        Callback that informs the DataProvider that an earlier requested subject has now been discarded.

         

        Parameters:
        subject - The subject that has been discarded.