org.apache.cocoon.util
Class SoftSourceCache

java.lang.Object
  extended byorg.apache.cocoon.util.SoftSourceCache
All Implemented Interfaces:
SourceCache

public class SoftSourceCache
extends Object
implements SourceCache

Cache for objects created from a source. Objects and keys are held using SoftReference and are thus cleanable by the garbage collector if the VM is low on memory. If an object cannot be found in the cache or the source's validity has expired, the source is reread and the object is recreated using the registered SourceReloader.

Since:
2.1.4
Version:
CVS $Id: SoftSourceCache.java 156626 2005-03-09 09:43:39Z cziegeler $
Author:
Christian Haul

Field Summary
 
Fields inherited from interface org.apache.cocoon.util.SourceCache
ROLE
 
Constructor Summary
SoftSourceCache()
           
 
Method Summary
 Object getObject(SourceResolver resolver, Object key, String uri, Object parameter)
          Retrieve an object from the cache.
 void register(SourceReloader reloader)
          Register a source reloader that will recreate cached objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftSourceCache

public SoftSourceCache()
Method Detail

register

public void register(SourceReloader reloader)
Description copied from interface: SourceCache
Register a source reloader that will recreate cached objects. Often, this will be done using an anonymous nested class.

Specified by:
register in interface SourceCache
Parameters:
reloader -

getObject

public Object getObject(SourceResolver resolver,
                        Object key,
                        String uri,
                        Object parameter)
                 throws MalformedURLException,
                        IOException
Description copied from interface: SourceCache
Retrieve an object from the cache. Transparently reloads and recreates objects using the registered source reloader if the objects identified by the key hasn't been cached or has been cleared from the cache, or source has changed.

Specified by:
getObject in interface SourceCache
Parameters:
resolver - A source resolver to use.
key - An object used as a key to the cached object.
uri - A string holding the URI.
parameter - Parameters to pass to the source reloader.
Returns:
Cached object.
Throws:
MalformedURLException
IOException


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.