Class DataStoreSource

java.lang.Object
com.github.cafapi.common.util.ref.DataSource
com.github.workerframework.api.DataStoreSource

public class DataStoreSource extends DataSource
An implementation of a DataSource that uses a Worker DataStore and a CAF Codec.
  • Constructor Details

    • DataStoreSource

      public DataStoreSource(DataStore dataStore, Codec codec)
      Create a new DataStoreSource.
      Parameters:
      dataStore - the store of remote data
      codec - the method to decode remote data into returned objects
  • Method Details

    • getObject

      public <T> T getObject(String ref, Class<T> clazz) throws DataSourceException
      Description copied from class: DataSource
      Retrieve an object of the specified class identified by a specific reference.
      Specified by:
      getObject in class DataSource
      Type Parameters:
      T - the type of the object instance
      Parameters:
      ref - the reference that points to an instance of an object of the specified class
      clazz - the class of the object instance the reference points to
      Returns:
      the object instance of the specified class identified by the specified reference
      Throws:
      DataSourceException - if the object instance cannot be acquired
    • getStream

      public InputStream getStream(String ref) throws DataSourceException
      Description copied from class: DataSource
      Retrieve a stream of data identified by a specific reference.
      Specified by:
      getStream in class DataSource
      Parameters:
      ref - the reference that points to a stream of data
      Returns:
      a stream of data identified by the specified reference
      Throws:
      DataSourceException - if the data stream cannot be acquired
    • getDataSize

      public long getDataSize(String ref) throws DataSourceException
      Description copied from class: DataSource
      Determine the size of the data abstracted.
      Specified by:
      getDataSize in class DataSource
      Parameters:
      ref - the reference that points to the data
      Returns:
      the size of the data, in bytes
      Throws:
      DataSourceException - if the data size cannot be acquired