Class ResourceCacheImpl
- java.lang.Object
-
- org.apache.velocity.runtime.resource.ResourceCacheImpl
-
- All Implemented Interfaces:
ResourceCache
public class ResourceCacheImpl extends java.lang.Object implements ResourceCache
Default implementation of the resource cache for the default ResourceManager. The cache uses a least recently used (LRU) algorithm, with a maximum size specified via theresource.manager.cache.sizeproperty (idenfied by theRuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZEconstant). This property get be set to0or less for a greedy, unbounded cache (the behavior from pre-v1.5).- Version:
- $Id: ResourceCacheImpl.java 898032 2010-01-11 19:51:03Z nbubna $
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.MapcacheCache storage, assumed to be thread-safe.protected RuntimeServicesrsvcRuntime services, generally initialized by theinitialize()method.
-
Constructor Summary
Constructors Constructor Description ResourceCacheImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.IteratorenumerateKeys()returns an Iterator of Keys in the cache.Resourceget(java.lang.Object key)retrieves a Resource from the cachevoidinitialize(RuntimeServices rs)initializes the ResourceCache.Resourceput(java.lang.Object key, Resource value)stores a Resource in the cacheResourceremove(java.lang.Object key)removes a Resource from the cache
-
-
-
Field Detail
-
cache
protected java.util.Map cache
Cache storage, assumed to be thread-safe.
-
rsvc
protected RuntimeServices rsvc
Runtime services, generally initialized by theinitialize()method.
-
-
Method Detail
-
initialize
public void initialize(RuntimeServices rs)
Description copied from interface:ResourceCacheinitializes the ResourceCache. Will be called before any utilization- Specified by:
initializein interfaceResourceCache- Parameters:
rs- RuntimeServices to use for logging, etc- See Also:
ResourceCache.initialize(org.apache.velocity.runtime.RuntimeServices)
-
get
public Resource get(java.lang.Object key)
Description copied from interface:ResourceCacheretrieves a Resource from the cache- Specified by:
getin interfaceResourceCache- Parameters:
key- key for Resource to be retrieved- Returns:
- Resource specified or null if not found
- See Also:
ResourceCache.get(java.lang.Object)
-
put
public Resource put(java.lang.Object key, Resource value)
Description copied from interface:ResourceCachestores a Resource in the cache- Specified by:
putin interfaceResourceCache- Parameters:
key- key to associate with the Resourcevalue- Resource to be stored- Returns:
- existing Resource stored under this key, or null if none
- See Also:
ResourceCache.put(java.lang.Object, org.apache.velocity.runtime.resource.Resource)
-
remove
public Resource remove(java.lang.Object key)
Description copied from interface:ResourceCacheremoves a Resource from the cache- Specified by:
removein interfaceResourceCache- Parameters:
key- resource to be removed- Returns:
- stored under key
- See Also:
ResourceCache.remove(java.lang.Object)
-
enumerateKeys
public java.util.Iterator enumerateKeys()
Description copied from interface:ResourceCachereturns an Iterator of Keys in the cache.- Specified by:
enumerateKeysin interfaceResourceCache- Returns:
- An Iterator of Keys in the cache.
- See Also:
ResourceCache.enumerateKeys()
-
-