Package com.caplin.motif.datasource
Class CachedAdapter
java.lang.Object
com.caplin.motif.datasource.CachedAdapter
- Direct Known Subclasses:
CommoditiesTradeAdapter
,FXOrderAdapter
,FXPrecisionAdapter
,FXRatesAdapter
,FXTradeAdapter
,MMCalendarAdapter
,MMRatesAdapter
,UserDetailsAdapter
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.
CachedAdapter adapter = new CachedAdapter(dataSource); CachingPublisher publisher = adapter.createCachedPublisher(new NamespacePrefix("/FX"), this, new FXSubjectParser());
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCachedAdapter
(com.caplin.datasource.DataSource dataSource) Constructs a CachedAdapter to wrap requests made to the specified dataSource. -
Method Summary
Modifier and TypeMethodDescription<T extends SubjectInfo>
com.caplin.datasource.publisher.CachingPublishercreateCachedPublisher
(com.caplin.datasource.namespace.Namespace namespace, CachedDataProvider<T> dataProvider, SubjectParser<T> parser) Creates anCachingPublisher
that will publish messages on the specified Namespace.<T extends SubjectInfo>
com.caplin.datasource.publisher.CachingPublishercreateCachedPublisher
(String metricNamePrefix, com.caplin.datasource.namespace.Namespace namespace, CachedDataProvider<T> dataProvider, SubjectParser<T> parser) Creates anActivePublisher
that will publish messages on the specified Namespace.
-
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 anCachingPublisher
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 anActivePublisher
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.
-