Class CachedAdapter

java.lang.Object
com.caplin.motif.datasource.CachedAdapter
Direct Known Subclasses:
CommoditiesTradeAdapter, FXOrderAdapter, FXPrecisionAdapter, FXRatesAdapter, FXTradeAdapter, MMCalendarAdapter, MMRatesAdapter, UserDetailsAdapter

public class CachedAdapter extends Object

Provides a Single-Request, Single-Discard DataSource API for a DataProvider and simplifies the Publisher API. This class also handles multiple peer requests for the same subscription by maintaining a cache, which is useful for fail-over and redundancy scenarios.

Usage:
 CachedAdapter adapter = new CachedAdapter(dataSource);
 CachingPublisher publisher = adapter.createCachedPublisher(new NamespacePrefix("/FX"), this, new FXSubjectParser());
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final com.caplin.datasource.DataSource
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CachedAdapter(com.caplin.datasource.DataSource dataSource)
    Constructs a CachedAdapter to wrap requests made to the specified dataSource.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends SubjectInfo>
    com.caplin.datasource.publisher.CachingPublisher
    createCachedPublisher(com.caplin.datasource.namespace.Namespace namespace, CachedDataProvider<T> dataProvider, SubjectParser<T> parser)
    Creates an CachingPublisher that will publish messages on the specified Namespace.
    <T extends SubjectInfo>
    com.caplin.datasource.publisher.CachingPublisher
    createCachedPublisher(String metricNamePrefix, com.caplin.datasource.namespace.Namespace namespace, CachedDataProvider<T> dataProvider, SubjectParser<T> parser)
    Creates an ActivePublisher that will publish messages on the specified Namespace.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dataSource

      protected final com.caplin.datasource.DataSource dataSource
  • Constructor Details

    • CachedAdapter

      public CachedAdapter(com.caplin.datasource.DataSource dataSource)
      Constructs a CachedAdapter to wrap requests made to the specified dataSource.
      Parameters:
      dataSource - The dataSource to wrap.
  • Method Details

    • createCachedPublisher

      public <T extends SubjectInfo> com.caplin.datasource.publisher.CachingPublisher createCachedPublisher(com.caplin.datasource.namespace.Namespace namespace, CachedDataProvider<T> dataProvider, SubjectParser<T> parser)
      Creates an CachingPublisher that will publish messages on the specified Namespace.

      This method uses a subject parser which allows subjects to be parsed into meaningful request objects.

      Type Parameters:
      T - The generic type erasure to provide compile time type-safety
      Parameters:
      namespace - The namespace that the publisher will publish on.
      dataProvider - The provider that will accept requests and discards.
      parser - The parser that will parse subject requests into a object representation of the request.
      Returns:
      The CachingPublisher to use for publishing messages.
    • createCachedPublisher

      public <T extends SubjectInfo> com.caplin.datasource.publisher.CachingPublisher createCachedPublisher(String metricNamePrefix, com.caplin.datasource.namespace.Namespace namespace, CachedDataProvider<T> dataProvider, SubjectParser<T> parser)
      Creates an ActivePublisher that will publish messages on the specified Namespace.

      This method uses a subject parser which allows subjects to be parsed into meaningful request objects

      Type Parameters:
      T - The generic type erasure to provide compile time type-safety
      Parameters:
      metricNamePrefix - The prefix that will be used on publisher metrics.
      namespace - The namespace that the publisher will publish on.
      dataProvider - The provider that will accept requests and discards.
      parser - The parser that will parse subject requests into a object representation of the request.
      Returns:
      The CachingPublisher to use for publishing messages.