de.neteye.actioncache
Class ActionCache

java.lang.Object
  |
  +--de.neteye.actioncache.AbstractCache
        |
        +--de.neteye.actioncache.ActionCache
All Implemented Interfaces:
java.io.Serializable

public final class ActionCache
extends AbstractCache

Cache implementation using ActionCacheItem objects

Version:
$Revision: 1.3 $
Author:
Felix Gnass
See Also:
Serialized Form

Field Summary
static java.lang.String RESPONSE_WRAPPER
          The request attribute under which the ResponseWrapper is stored
 
Method Summary
 CacheItem createCacheItem(java.lang.Object key)
           
 ActionCacheItem getActionCacheItem(java.lang.Object key)
           
 java.io.File getCacheDir()
           
static ActionCache newInstance(int capacity, java.io.File cacheDir)
           
 void persist()
           
 javax.servlet.http.HttpServletResponse wrapResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.struts.action.Action action, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping)
          Wraps the response into an ActionCacheResponseWrapper if it needs to be cached.
 
Methods inherited from class de.neteye.actioncache.AbstractCache
getItem, setCapacity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESPONSE_WRAPPER

public static final java.lang.String RESPONSE_WRAPPER
The request attribute under which the ResponseWrapper is stored

See Also:
Constant Field Values
Method Detail

getCacheDir

public java.io.File getCacheDir()

createCacheItem

public CacheItem createCacheItem(java.lang.Object key)
                          throws java.io.IOException
Specified by:
createCacheItem in class AbstractCache
java.io.IOException

getActionCacheItem

public ActionCacheItem getActionCacheItem(java.lang.Object key)

newInstance

public static ActionCache newInstance(int capacity,
                                      java.io.File cacheDir)
                               throws java.lang.InstantiationException
java.lang.InstantiationException

persist

public void persist()

wrapResponse

public javax.servlet.http.HttpServletResponse wrapResponse(javax.servlet.http.HttpServletRequest request,
                                                           javax.servlet.http.HttpServletResponse response,
                                                           org.apache.struts.action.Action action,
                                                           org.apache.struts.action.ActionForm form,
                                                           org.apache.struts.action.ActionMapping mapping)
                                                    throws java.lang.Exception
Wraps the response into an ActionCacheResponseWrapper if it needs to be cached. If theres a valid cache item for the cache key, the cached content is written to the response and null is returned. If the action does not implement CacheableAction, the original response is returned. This method was formerly part of the RequestProcessor(s) and has been moved here to avoid duplicate code. Hopefully in an upcoming struts release that supports RequestProcessor chaining, the code can be moved back to the RequestProcessor where it belongs.

java.lang.Exception
Since:
1.1.2