TUM CCSM Commons

edu.tum.cs.commons.factory
Class SoftRefCachingParameterizedFactory<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.SoftRefCacheBase<I,I,E,X>
          extended by edu.tum.cs.commons.cache.SoftRefStraightCacheBase<P,T,X>
              extended by edu.tum.cs.commons.factory.SoftRefCachingParameterizedFactory<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 SoftRefCachingParameterizedFactory<T,P,X extends java.lang.Exception>
extends SoftRefStraightCacheBase<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 SoftRefStraightCacheBase is used.

Version:
$Rev: 26268 $
Author:
hummelb, $Author: juergens $
Rating:
GREEN Hash: B334A34CE1769C1621A5E7A691D2270C

Field Summary
 
Fields inherited from class edu.tum.cs.commons.cache.SoftRefCacheBase
cache
 
Constructor Summary
SoftRefCachingParameterizedFactory(IParameterizedFactory<T,P,X> inner)
          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.SoftRefStraightCacheBase
getHashKey
 
Methods inherited from class edu.tum.cs.commons.cache.SoftRefCacheBase
getItem, getStatistics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftRefCachingParameterizedFactory

public SoftRefCachingParameterizedFactory(IParameterizedFactory<T,P,X> inner)
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 SoftRefCacheBase.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