public class FailsafeAmountMoneyExchangeRateRetriever extends Object implements AmountMoneyExchangeRateRetriever
AmountMoneyExchangeRateRetrievers available for
retrieval and wraps calls to retrieveExchangeRate(org.jscience.economics.money.Currency)
in a try-catch block and delegates to the next candidate if the call to the
preceeding fails.
Supported currencies are those supported by at least one
AmountMoneyExchangeRateRetriever which returns a result. That's
necessary because otherwise one failing
AmountMoneyExchangeRateRetriever causes the
FailsafeAmountMoneyExchangeRateRetriever to fail which isn't
intended.
Note that this doesn't make the call really, but only
almost failsafe. The name is still fine imo.| Modifier and Type | Field and Description |
|---|---|
static int |
AVAILABLE_RETRIEVER_MIN_DEFAULT |
| Constructor and Description |
|---|
FailsafeAmountMoneyExchangeRateRetriever(File cacheFileDir) |
FailsafeAmountMoneyExchangeRateRetriever(File cacheFileDir,
long fileCacheExpirationMillis) |
FailsafeAmountMoneyExchangeRateRetriever(int availableRetrieverMin,
File cacheFileDir,
long fileCacheExpirationMillis) |
FailsafeAmountMoneyExchangeRateRetriever(int availableRetrieverMin,
Set<AmountMoneyExchangeRateRetriever> fallbackRetrievers) |
FailsafeAmountMoneyExchangeRateRetriever(Set<AmountMoneyExchangeRateRetriever> fallbackRetrievers) |
| Modifier and Type | Method and Description |
|---|---|
Set<org.jscience.economics.money.Currency> |
getSupportedCurrencies()
In order to be really failsafe this method only returns currencies which
are supported by all used exchange rate retrievers.
|
void |
retrieveExchangeRate(org.jscience.economics.money.Currency currency)
Sets the
exchangeRate property on the passed currency
relative to a reference currency. |
public static final int AVAILABLE_RETRIEVER_MIN_DEFAULT
public FailsafeAmountMoneyExchangeRateRetriever(File cacheFileDir) throws IOException
IOExceptionpublic FailsafeAmountMoneyExchangeRateRetriever(File cacheFileDir, long fileCacheExpirationMillis) throws IOException
IOExceptionpublic FailsafeAmountMoneyExchangeRateRetriever(int availableRetrieverMin,
File cacheFileDir,
long fileCacheExpirationMillis)
throws IOException
availableRetrieverMin - the minimum number of available retrievers
which are triedcacheFileDir - Since
FailsafeAmountMoneyExchangeRateRetriever will manage multiple
possibly caching retrievers, a directory needs to be used for cache
files.fileCacheExpirationMillis - the expiraton time of the file cache in
millisecondsIOException - if the creation of cacheFileDir failspublic FailsafeAmountMoneyExchangeRateRetriever(Set<AmountMoneyExchangeRateRetriever> fallbackRetrievers)
public FailsafeAmountMoneyExchangeRateRetriever(int availableRetrieverMin,
Set<AmountMoneyExchangeRateRetriever> fallbackRetrievers)
public Set<org.jscience.economics.money.Currency> getSupportedCurrencies() throws AmountMoneyExchangeRateRetrieverException
getSupportedCurrencies in interface AmountMoneyExchangeRateRetrieverAmountMoneyExchangeRateRetrieverException - if an exception
unrelated to a network failure or missing network connection occuredpublic void retrieveExchangeRate(org.jscience.economics.money.Currency currency)
throws AmountMoneyExchangeRateRetrieverException
AmountMoneyExchangeRateRetrieverexchangeRate property on the passed currency
relative to a reference currency.retrieveExchangeRate in interface AmountMoneyExchangeRateRetrievercurrency - the currency to retrieve forAmountMoneyExchangeRateRetrieverException - if an exception
unrelated to a network failure or missing network connection occuredCopyright © 2018. All rights reserved.