TUM CCSM Commons

edu.tum.cs.commons.factory
Class LRUCachingParameterizedFactory<T,P,X extends java.lang.Exception>

java.lang.Object
  extended by edu.tum.cs.commons.cache.CacheBase<I,H,E,X>
      extended by edu.tum.cs.commons.cache.LRUCacheBase<I,I,E,X>
          extended by edu.tum.cs.commons.cache.LRUStraightCacheBase<P,T,X>
              extended by edu.tum.cs.commons.factory.LRUCachingParameterizedFactory<T,P,X>
Type Parameters:
T - Type that gets created by the factory.
P - Parameter that is used for creation.
X - Exception that can get thrown during execution of the factory method. If no exception is thrown, use NeverThrownRuntimeException.
All Implemented Interfaces:
IParameterizedFactory<T,P,X>

public class LRUCachingParameterizedFactory<T,P,X extends java.lang.Exception>
extends LRUStraightCacheBase<P,T,X>
implements IParameterizedFactory<T,P,X>

Caching factory which can reuse created objects. Creation is delegated to an inner factory, while for caching a LRUCacheBase is used.

Version:
$Rev: 27446 $
Author:
hummelb, $Author: heineman $
Rating:
GREEN Hash: 5D97F2DF67786BC74BEB3611B6017360

Constructor Summary
LRUCachingParameterizedFactory(IParameterizedFactory<T,P,X> inner, int maxSize)
          Constructor.
 
Method Summary
 T create(P parameter)
          Factory method
protected  T obtainItem(P identifier)
          Extenders of the cache class must implemented that method to define the item acquisition mechanism.
 
Methods inherited from class edu.tum.cs.commons.cache.LRUStraightCacheBase
getHashKey
 
Methods inherited from class edu.tum.cs.commons.cache.LRUCacheBase
getItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LRUCachingParameterizedFactory

public LRUCachingParameterizedFactory(IParameterizedFactory<T,P,X> inner,
                                      int maxSize)
Constructor.

Method Detail

obtainItem

protected T obtainItem(P identifier)
                throws X extends java.lang.Exception
Extenders of the cache class must implemented that method to define the item acquisition mechanism.

Delegates to the inner factory.

Specified by:
obtainItem in class CacheBase<P,P,T,X extends java.lang.Exception>
Parameters:
identifier - identifer unambiguously identifying the item.
Returns:
the item to cache.
Throws:
X extends java.lang.Exception

create

public T create(P parameter)
         throws X extends java.lang.Exception
Factory method

Forwards to the LRUCacheBase.getItem(Object) method.

Specified by:
create in interface IParameterizedFactory<T,P,X extends java.lang.Exception>
Throws:
X extends java.lang.Exception

TUM CCSM Commons

TUM CCSM Commons - 2.7