com.arsdigita.web
Class PathMapCache

java.lang.Object
  extended bycom.arsdigita.web.PathMapCache

public abstract class PathMapCache
extends Object

Maintains a mapping of URL fragments to objects.

Since:
2004-01-14
Version:
$Revision: #6 $ $DateTime: 2004/04/07 16:07:11 $
Author:
Vadim Nasardinov (vadimn@redhat.com)

Constructor Summary
protected PathMapCache(String cacheID)
           
 
Method Summary
protected  void clearAll()
           
protected  Object get(String path)
          Returns the object mapped to the normalized path or its longest possible subpath.
protected  boolean isCached(String path)
           
protected abstract  String normalize(String path)
          Given a path like "/foo/bar/baz/quux", returns either "/foo/bar/baz/" or "/foo/bar/baz/quux/".
protected  void put(String path, Object value)
           
protected abstract  void refresh()
           
protected  void refreshAfterCommit()
          Sets up and tears down the context in which refresh() can be run.
protected abstract  Object retrieve(String path)
          This method is called when PathMapCache cannot find a cached value mapped to this path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathMapCache

protected PathMapCache(String cacheID)
Throws:
IllegalArgumentException - if cacheID is not a globally unique identifer.
See Also:
CacheTable.CacheTable(String)
Method Detail

get

protected final Object get(String path)
Returns the object mapped to the normalized path or its longest possible subpath. May return null.

If no object is cached in memory for this path or any of its subpaths, this method will try to retrieve the object by delegating to retrieve(String). If retrieval returns a non-null object, it will be cached in memory so that subsequent calls to get do not have to call retrieve again.


isCached

protected boolean isCached(String path)

put

protected void put(String path,
                   Object value)

clearAll

protected void clearAll()

refreshAfterCommit

protected void refreshAfterCommit()
Sets up and tears down the context in which refresh() can be run. If you need to update the cache after one of your previously cached (persistent) objects changes, then you should implement refresh() and call refreshAfterCommit in your persistent object's DomainObject.beforeSave() and/or DomainObject.afterDelete() methods.


normalize

protected abstract String normalize(String path)
Given a path like "/foo/bar/baz/quux", returns either "/foo/bar/baz/" or "/foo/bar/baz/quux/".


retrieve

protected abstract Object retrieve(String path)
This method is called when PathMapCache cannot find a cached value mapped to this path. If the returned value is not null, it will be cached. Therefore, care must be taken to ensure that the value is cacheable across transactions. (For example, if you the value returned by this method is a DataObject, it must be disconnected before being returned.)


refresh

protected abstract void refresh()


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC