use of javax.money.spi.CurrencyProviderSpi in project jsr354-ri-bp by JavaMoney.
the class DefaultMonetaryCurrenciesSingletonSpi method getCurrencies.
@Override
public Set<CurrencyUnit> getCurrencies(CurrencyQuery query) {
Set<CurrencyUnit> result = new HashSet<>();
List<CurrencyProviderSpi> providers = collectProviders(query);
for (CurrencyProviderSpi spi : providers) {
try {
result.addAll(spi.getCurrencies(query));
} catch (Exception e) {
Logger.getLogger(DefaultMonetaryCurrenciesSingletonSpi.class.getName()).log(Level.SEVERE, "Error loading currency provider names for " + spi.getClass().getName(), e);
}
}
return result;
}
use of javax.money.spi.CurrencyProviderSpi in project jsr354-ri by JavaMoney.
the class DefaultMonetaryCurrenciesSingletonSpi method getCurrencies.
@Override
public Set<CurrencyUnit> getCurrencies(CurrencyQuery query) {
Set<CurrencyUnit> result = new HashSet<>();
List<CurrencyProviderSpi> providers = collectProviders(query);
for (CurrencyProviderSpi spi : providers) {
try {
result.addAll(spi.getCurrencies(query));
} catch (Exception e) {
Logger.getLogger(DefaultMonetaryCurrenciesSingletonSpi.class.getName()).log(Level.SEVERE, "Error loading currency provider names for " + spi.getClass().getName(), e);
}
}
return result;
}
use of javax.money.spi.CurrencyProviderSpi in project jsr354-ri-bp by JavaMoney.
the class DefaultMonetaryCurrenciesSingletonSpi method getDefaultProviderChain.
/**
* This default implementation simply returns all providers defined in arbitrary order.
*
* @return the default provider chain, never null.
*/
@Override
public List<String> getDefaultProviderChain() {
List<String> provList = new ArrayList<>();
String defaultChain = MonetaryConfig.getConfig().get("currencies.default-chain");
if (defaultChain != null) {
String[] items = defaultChain.split(",");
for (String item : items) {
if (getProviderNames().contains(item.trim())) {
provList.add(item);
} else {
Logger.getLogger(getClass().getName()).warning("Ignoring non existing default provider: " + item);
}
}
} else {
for (CurrencyProviderSpi currencyProviderSpi : Bootstrap.getServices(CurrencyProviderSpi.class)) {
provList.add(currencyProviderSpi.getProviderName());
}
}
return provList;
}
Aggregations