【Java开源代码栏目提醒】:以下是网学会员为您推荐的Java开源代码-TransactionHistoryManager.java,希望本篇文章对您学习有所帮助。
/**
* Instances of this class retrieve the TransactionHistory
* associated with an ItemID.
*/
class TransactionHistoryManager {
private TransactionHistoryCache cache
= new TransactionHistoryCache();
private TransactionHistoryFetcher server
= new TransactionHistoryFetcher();
/**
* Fetch an transaction history for the given item id from
* the internal cache or timekeeping server if the history
* is not found in the internal cache.
* @param id the id of the item that the history is of.
* @return The transaction history or null if the
* transaction history is not found.
*/
TransactionHistory fetchHistory(ItemID id) {
TransactionHistory history = cache.fetchHistory(id);
if (history == null) { // if not in cache try server.
history = server.fetchHistory(id);
if (history != null) { // Got the history from the server
// put history in the cache
cache.addHistory(history);
} // if != null
} // if == null
return history;
} // fetchHistory(ItemID)
} // class TransactionHistoryManager