|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.riotfamily.cachius.spring.AbstractCacheableController
public abstract class AbstractCacheableController
Abstract base class for cacheable controllers.
Field Summary |
---|
Fields inherited from interface org.riotfamily.cachius.spring.CacheableController |
---|
CACHE_ETERNALLY |
Constructor Summary | |
---|---|
AbstractCacheableController()
|
Method Summary | |
---|---|
protected void |
appendCacheKey(StringBuffer key,
HttpServletRequest request)
Subclasses may overwrite this method to append values to the cache-key. |
protected boolean |
bypassCache(HttpServletRequest request)
Returns whether the cache should be bypassed. |
protected String |
getBeanName()
|
String |
getCacheKey(HttpServletRequest request)
Returns the cache-key for the request. |
protected String |
getCacheKeyInternal(HttpServletRequest request)
Returns the actual cache-key. |
long |
getLastModified(HttpServletRequest request)
The default implementation returns System.currentTimeMillis() so that the item is
refreshed as soon as it expires. |
long |
getTimeToLive()
The default implementation returns 0 so that
getLastModified(HttpServletRequest) is invoked every time the
controller is requested. |
void |
setAddUriToCacheKey(boolean addUriToCacheKey)
Sets whether the (originating) URI should be included in the cache-key. |
void |
setBeanName(String beanName)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.web.servlet.mvc.Controller |
---|
handleRequest |
Constructor Detail |
---|
public AbstractCacheableController()
Method Detail |
---|
public final void setBeanName(String beanName)
setBeanName
in interface BeanNameAware
protected String getBeanName()
public void setAddUriToCacheKey(boolean addUriToCacheKey)
false
if the controller looks the same
on every page, i.e. does not dependent on the URI. The default is
true
which is safe (as it will rule out wrong content to
be displayed due to identical cache-keys) but could lead to many
identical cache items.
getCacheKeyInternal(HttpServletRequest)
protected boolean bypassCache(HttpServletRequest request)
false
.
public final String getCacheKey(HttpServletRequest request)
getCacheKeyInternal(HttpServletRequest)
, unless
bypassCache(HttpServletRequest)
returns true
.
getCacheKey
in interface CacheableController
protected String getCacheKeyInternal(HttpServletRequest request)
getCacheKey()
if bypassCache()
returned false
.
The method creates a StringBuffer containing either the bean-name or the
originating path
and, in case of an include or forward, the
nested path
.
The StringBuffer is passed to appendCacheKey(StringBuffer, HttpServletRequest)
,
allowing subclasses to add additional information.
protected void appendCacheKey(StringBuffer key, HttpServletRequest request)
getCacheKeyInternal(HttpServletRequest)
public long getTimeToLive()
0
so that
getLastModified(HttpServletRequest)
is invoked every time the
controller is requested.
getTimeToLive
in interface CacheableController
public long getLastModified(HttpServletRequest request)
System.currentTimeMillis()
so that the item is
refreshed as soon as it expires. Subclasses should override this
method to return something reasonable.
getLastModified
in interface CacheableController
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |