javax.money.convert.ProviderContext Java Examples

The following examples show how to use javax.money.convert.ProviderContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactiveKnowmExchangeProvider.java    From consensusj with Apache License 2.0 6 votes vote down vote up
private synchronized void initialize()  {
    if (!initialized) {
        log.info("initializing, calling createExchange()");
        // createExchange w/o exchangeSpecification does a remote initialization that takes approximately 1.5 seconds
        if (exchangeSpecification != null) {
            exchange = ExchangeFactory.INSTANCE.createExchange(exchangeSpecification);
        } else {
            exchange = ExchangeFactory.INSTANCE.createExchange(exchangeClassName);
        }
        log.info("initializing, getting name");
        name = exchange.getExchangeSpecification().getExchangeName();
        providerContext = ProviderContext.of(name, RateType.DEFERRED);
        marketDataService = exchange.getMarketDataService();
        initialized = true;
        log.info("initialized");
    }
    log.info("exiting");
}
 
Example #2
Source File: CompoundRateProvider.java    From jsr354-ri with Apache License 2.0 6 votes vote down vote up
private static ProviderContext createContext(Iterable<ExchangeRateProvider> providers) {
    Set<RateType> rateTypeSet = new HashSet<>();
    StringBuilder providerName = new StringBuilder("Compound: ");
    List<ProviderContext> childContextList = new ArrayList<>();
    for (ExchangeRateProvider exchangeRateProvider : providers) {
        childContextList.add(exchangeRateProvider.getContext());
        providerName.append(exchangeRateProvider.getContext().getProviderName());
        providerName.append(',' );
        rateTypeSet.addAll(exchangeRateProvider.getContext().getRateTypes());
    }
    providerName.setLength(providerName.length() - 1);

    ProviderContextBuilder builder = ProviderContextBuilder.of(providerName.toString(), rateTypeSet);
    builder.set(CHILD_PROVIDER_CONTEXTS_KEY, childContextList);
    return builder.build();
}
 
Example #3
Source File: KnowmExchangeRateProvider.java    From consensusj with Apache License 2.0 5 votes vote down vote up
public synchronized void initialize()  {
    if (!initialized) {
        initialized = true;
        exchange = ExchangeFactory.INSTANCE.createExchange(exchangeClassName);
        name = exchange.getExchangeSpecification().getExchangeName();
        providerContext = ProviderContext.of(name, RateType.DEFERRED);
        marketDataService = exchange.getMarketDataService();
    }
}
 
Example #4
Source File: ECBAbstractRateProvider.java    From jsr354-ri with Apache License 2.0 5 votes vote down vote up
ECBAbstractRateProvider(ProviderContext context) {
      super(context);
this.context = context;
      saxParserFactory.setNamespaceAware(false);
      saxParserFactory.setValidating(false);
      LoaderService loader = Bootstrap.getService(LoaderService.class);
      loader.addLoaderListener(this, getDataId());
      loader.loadDataAsync(getDataId());
  }
 
Example #5
Source File: YahooAbstractRateProvider.java    From javamoney-lib with Apache License 2.0 5 votes vote down vote up
YahooAbstractRateProvider(ProviderContext context) {
      super(context);
this.context = context;
      final LoaderService loader = Bootstrap.getService(LoaderService.class);
      loader.addLoaderListener(this, getDataId());
      loader.loadDataAsync(getDataId());
  }
 
Example #6
Source File: YahooRateReadingHandler.java    From javamoney-lib with Apache License 2.0 4 votes vote down vote up
public YahooRateReadingHandler(final Map<LocalDate, Map<String, ExchangeRate>> excangeRates,
		final ProviderContext context) {
	this.excangeRates = excangeRates;
	this.context = context;
}
 
Example #7
Source File: AbstractRateProvider.java    From jsr354-ri with Apache License 2.0 4 votes vote down vote up
@Override
public ProviderContext getContext() {
    return context;
}
 
Example #8
Source File: USFederalReserveRateProvider.java    From javamoney-lib with Apache License 2.0 4 votes vote down vote up
public USFederalReserveRateProvider(ProviderContext providerContext) {
    super(providerContext);
    initalize();
}
 
Example #9
Source File: ExchangeRateProviderMock.java    From jsr354-ri with Apache License 2.0 4 votes vote down vote up
@Override
public ProviderContext getContext() {
    // TODO Auto-generated method stub
    return null;
}
 
Example #10
Source File: KnowmExchangeRateProvider.java    From consensusj with Apache License 2.0 4 votes vote down vote up
@Override
public ProviderContext getContext() {
    return providerContext;
}
 
Example #11
Source File: IMFRateReadingHandler.java    From jsr354-ri with Apache License 2.0 4 votes vote down vote up
IMFRateReadingHandler(Map<String, CurrencyUnit> currenciesByName, ProviderContext context) {
	this.currenciesByName = currenciesByName;
	this.context = context;
}
 
Example #12
Source File: IMFAbstractRateProvider.java    From jsr354-ri with Apache License 2.0 4 votes vote down vote up
public IMFAbstractRateProvider(ProviderContext providerContext) {
	super(providerContext);
	this.context = providerContext;
	handler = new IMFRateReadingHandler(CURRENCIES_BY_NAME, context);
}
 
Example #13
Source File: USFederalReserveRateReadingHandler.java    From javamoney-lib with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new handler.
 *
 * @param historicRates
 *            the rates, not null.
 * @param context
 *            the context, not null.
 */
USFederalReserveRateReadingHandler(Map<LocalDate, Map<String, ExchangeRate>> historicRates, ProviderContext context) {
    this.historicRates = historicRates;
    this.context = context;
}
 
Example #14
Source File: AbstractRateProvider.java    From jsr354-ri with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor.
 *
 * @param providerContext the {@link ProviderContext}, not null.
 */
public AbstractRateProvider(ProviderContext providerContext) {
    Objects.requireNonNull(providerContext);
    this.context = providerContext;
}
 
Example #15
Source File: ECBRateReadingHandler.java    From jsr354-ri with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new handler.
 * @param historicRates the rates, not null.
 * @param context the context, not null.
 */
ECBRateReadingHandler(Map<LocalDate, Map<String, ExchangeRate>> historicRates, ProviderContext context) {
    this.historicRates = historicRates;
    this.context = context;
}
 
Example #16
Source File: Conversions.java    From javamoney-examples with Apache License 2.0 2 votes vote down vote up
/**
 * Evaluate the Provider Context of the IMF provider. Optionally print the details to the console.
 *
 * @return the ConversionContext, not null.
 * @see javax.money.convert.MonetaryConversions
 * @see javax.money.convert.ExchangeRateProvider
 */
public ProviderContext getIMFProviderContext() {
    throw new UnsupportedOperationException();
}
 
Example #17
Source File: Conversions.java    From javamoney-examples with Apache License 2.0 2 votes vote down vote up
/**
 * Evaluate the Provider Context of the ECB provider. Optionally print the details to the console.
 *
 * @return the ConversionContext, not null.
 * @see javax.money.convert.MonetaryConversions
 * @see javax.money.convert.ExchangeRateProvider
 */
public ProviderContext getECBProviderContext() {
    throw new UnsupportedOperationException();
}
 
Example #18
Source File: Conversions.java    From javamoney-examples with Apache License 2.0 2 votes vote down vote up
/**
 * Evaluate the Provider Context of the ECB provider. Optionally print the details to the console.
 *
 * @return the ConversionContext, not null.
 * @see javax.money.convert.MonetaryConversions
 * @see javax.money.convert.ExchangeRateProvider
 */
public ProviderContext getDefaultProviderContext() {
    throw new UnsupportedOperationException();
}