Interface DataProvider


public interface DataProvider

The interface that must be implemented by a class that will actively publish data for DataSource objects that match a specific name pattern. Active publishing means that a class will only publish data on demand, it will not publish data if it has not specifically been requested.

The object that is created with a class that implements DataProvider should be registered using the DataProviderRegistrar.register(java.lang.String, com.caplin.transformer.module.DataProvider) method. When a request is made for an object name that matches the pattern the DataProvider was registered with, the request method will be invoked. If an object with a name that matches the pattern is discarded, the discard method will be invoked.

  • Method Summary

    Modifier and Type
    Method
    Description
    discard(int dataSourcePeerId, String objectName)
    Invoked when a discard is made for an object name that matches the pattern the DataProvider was registered for.
    request(int dataSourcePeerId, String objectName)
    Invoked when a request is made for an object name that matches the pattern the DataProvider was registered for.
  • Method Details

    • request

      DataProviderResponse request(int dataSourcePeerId, String objectName)

      Invoked when a request is made for an object name that matches the pattern the DataProvider was registered for. This method should decide whether it is able to provide data for the requested object or not, and return the corresponding DataProviderResponse.

      If this method returns DataProviderResponse.OK then the Transformer core will not request the object from any other DataProviders. If this method returns DataProviderResponse.DENY then the Transformer core will check if any other DataProviders have been registered that could supply the data for the specified object, and, if so, will have their request method invoked.

      If it is going to take a while to verify whether the provider can provide data for the specified object name (e.g. a query needs to be made to a database or to an external application), this method should return DataProviderResponse.OK, and carry out the verification on a separate thread. Once the verification is complete, the provider can publish the data if the object passed the verification, otherwise it should call DataCache.remove(objectName) to remove the object from the Transformer core.

      The provider should never attempt to contribute any data whilst this method is being called. If it needs to, it should do so on a separate thread.

      Parameters:
      dataSourcePeerId - The identifier for the data source peer that has requested the object.
      objectName - The name of the object that has been requested.
      Returns:
      DataProviderResponse.OK if the DataProvider is able to provide the data for the requested object, otherwise DataProviderResponse.DENY. If null is returned, the Transformer core will treat it as a DataProviderResponse.DENY response.
    • discard

      DataProviderResponse discard(int dataSourcePeerId, String objectName)

      Invoked when a discard is made for an object name that matches the pattern the DataProvider was registered for.

      If this method returns DataProviderResponse.OK then the Transformer core will not attempt to discard the object from any other DataProviders. If this method returns DataProviderResponse.DENY then the Transformer core will check if any other DataProviders have been registered that could have supplied the data for the specified object, and, if so, will have their discard method invoked.

      Parameters:
      dataSourcePeerId - The identifier for the data source peer that has discarded the object.
      objectName - The name of the object to be discarded.
      Returns:
      DataProviderResponse.OK if the DataProvider is providing the data for the discarded object, otherwise DataProviderResponse.DENY. If null is returned, the Transformer core will treat it as a DataProviderResponse.DENY response.