IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.bc.fx.impl
Class CachedRatesProvider

java.lang.Object
  extended by com.ibm.btt.bc.fx.impl.CachedRatesProvider
All Implemented Interfaces:
RatesProvider

public class CachedRatesProvider
extends java.lang.Object
implements RatesProvider

This class is a decorator with the mechanism used to cache exchange rates. This reduces the number of calls to the server to get these rates.


Constructor Summary
CachedRatesProvider(RatesProvider ratesProvider, long refreshInterval)
          Constructs an instance of the CachedRatesProvider class with an given rates provider to be cached and the interval to refresh the cache.
 
Method Summary
 java.util.Set<java.lang.String> getAllSupportedCurrencies()
          Returns all supported currency codes in a Set.
(package private)  int getCachedRatesNum()
          Returns the number of cached rates
 java.util.Set<java.lang.String> getDefinedMonetaryItems()
          Returns all defined monetary item types.
 java.math.BigDecimal getRate(RatesQueryRequest request, boolean isBuy)
          Returns the rate at which the financial institution buys or sells the destination currency.
 long getRefreshInterval()
          Returns the interval to refresh the rates cache.
 void setRefreshInterval(long refreshInterval)
          Sets the interval to refresh the rates cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachedRatesProvider

public CachedRatesProvider(RatesProvider ratesProvider,
                           long refreshInterval)
Constructs an instance of the CachedRatesProvider class with an given rates provider to be cached and the interval to refresh the cache.

Parameters:
ratesProvider - the given rates provider whose rates are to be cached
refreshInterval - the interval to refresh the cache
Method Detail

getRate

public java.math.BigDecimal getRate(RatesQueryRequest request,
                                    boolean isBuy)
                             throws ForeignExchangeException
Description copied from interface: RatesProvider
Returns the rate at which the financial institution buys or sells the destination currency.

Specified by:
getRate in interface RatesProvider
Parameters:
request - the RatesQueryRequest instance specifying the information of the query
isBuy - true if the requested rate is a buy rate, otherwise it should be false
Returns:
the rate at which the financial institution buys or sells the destination currency.
Throws:
ForeignExchangeException - occurs if there is an error accessing the rate

getRefreshInterval

public long getRefreshInterval()
Returns the interval to refresh the rates cache.

Returns:
the interval measured in millisecond

setRefreshInterval

public void setRefreshInterval(long refreshInterval)
Sets the interval to refresh the rates cache.

Parameters:
refreshInterval - the interval measured in millisecond

getAllSupportedCurrencies

public java.util.Set<java.lang.String> getAllSupportedCurrencies()
                                                          throws ForeignExchangeException
Description copied from interface: RatesProvider
Returns all supported currency codes in a Set.

Specified by:
getAllSupportedCurrencies in interface RatesProvider
Returns:
the Set containing all supported currency codes
Throws:
ForeignExchangeException - occurs if there is an error accessing the Set

getDefinedMonetaryItems

public java.util.Set<java.lang.String> getDefinedMonetaryItems()
                                                        throws ForeignExchangeException
Description copied from interface: RatesProvider
Returns all defined monetary item types.

Specified by:
getDefinedMonetaryItems in interface RatesProvider
Returns:
the Set containing all supported monetary item types
Throws:
ForeignExchangeException - occurs if there is an error accessing the Set

getCachedRatesNum

int getCachedRatesNum()
Returns the number of cached rates

Returns:
the number of cached rates

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2011