Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.opensymphony.oscache.web.tag
Class CacheTag

    java.lang.Object
      javax.servlet.jsp.tagext.TagSupport
          javax.servlet.jsp.tagext.BodyTagSupport
              com.opensymphony.oscache.web.tag.CacheTag

All Implemented Interfaces:
  javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally

public class CacheTag
extends javax.servlet.jsp.tagext.BodyTagSupport
implements javax.servlet.jsp.tagext.TryCatchFinally

CacheTag is a tag that allows for server-side caching of post-processed JSP content.

It also gives great programatic control over refreshing, flushing and updating the cache.

Usage Example:

         <%@ taglib uri="oscache" prefix="cache" %>
         <cache:cache key="mycache"
                     scope="application"
                     refresh="false"
                     time="30">
                  jsp content here... refreshed every 30 seconds
         </cache:cache>

Version:
  $Revision: 1.4 $
Author:
  Mike Cannon-Brookes, Todd Gochenour, Francois Beauregard, Alain Bergevin
See Also:
  Serialized Form

Field Summary

Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
`bodyContent`

Fields inherited from class javax.servlet.jsp.tagext.TagSupport
`id, pageContext`

Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
`EVAL_BODY_BUFFERED, EVAL_BODY_TAG`

Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
`EVAL_BODY_AGAIN`

Fields inherited from interface javax.servlet.jsp.tagext.Tag
`EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE`

Constructor Summary
`CacheTag()`

Method Summary
`int` | `doAfterBody()` After the cache body, either update the cache, serve new cached content or indicate an error.
`void` | `doCatch(java.lang.Throwable throwable)`
`int` | `doEndTag()` The end tag - clean up variables used.
`void` | `doFinally()`
`int` | `doStartTag()` The start of the tag.
`void` | `setCron(java.lang.String cron)` Sets the cron expression that should be used to expire content at specific dates and/or times.
`void` | `setDuration(java.lang.String duration)` Set the time this cache entry will be cached for.
`void` | `setGroups(java.lang.String groups)` Sets the groups for this cache entry.
`void` | `setKey(java.lang.String key)` Set the key for this cache entry.
`void` | `setLanguage(java.lang.String language)` Set the ISO-639 language code to distinguish different pages in application scope
`void` | `setMode(java.lang.String mode)` Setting this to `true` prevents the cache from writing any output to the response, however the JSP content is still cached as normal.
`void` | `setRefresh(boolean refresh)` This method allows the user to programatically decide whether the cached content should be refreshed immediately.
`void` | `setRefreshpolicyclass(java.lang.String refreshPolicyClass)` Class used to handle the refresh policy logic
`void` | `setRefreshpolicyparam(java.lang.String refreshPolicyParam)` Parameters that will be passed to the init method of the refresh policy instance.
`void` | `setScope(java.lang.String scope)` Set the scope of this cache.
`void` | `setTime(int time)` Set the time this cache entry will be cached for (in seconds)
`void` | `setUseBody(boolean useBody)` This controls whether or not the body of the tag is evaluated or used.

Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
`doInitBody, getBodyContent, getPreviousOut, release, setBodyContent`

Methods inherited from class javax.servlet.jsp.tagext.TagSupport
`findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface javax.servlet.jsp.tagext.Tag
`getParent, setPageContext, setParent`

Constructor Detail

### CacheTag

    public CacheTag()

Method Detail

### setDuration

    public void setDuration(java.lang.String duration)

  Set the time this cache entry will be cached for. A date and/or time in either ISO-8601 format or a simple format can be specified. The acceptable syntax for the simple format can be any one of the following:
  - 0 (seconds)
  - 0s (seconds)
  - 0m (minutes)
  - 0h (hours)
  - 0d (days)
  - 0w (weeks)

  Parameters:
    `duration` - The duration to cache this content (using either the simple or the ISO-8601 format). Passing in a duration of zero will turn off the caching, while a negative value will result in the cached content never expiring (ie, the cached content will always be served as long as it is present).

### setCron

    public void setCron(java.lang.String cron)

  Sets the cron expression that should be used to expire content at specific dates and/or times.

### setGroups

    public void setGroups(java.lang.String groups)

  Sets the groups for this cache entry. Any existing groups will be replaced.

  Parameters:
    `groups` - A comma-delimited list of groups that the cache entry belongs to.

### setKey

    public void setKey(java.lang.String key)

  Set the key for this cache entry.

  Parameters:
    `key` - The key for this cache entry.

### setLanguage

    public void setLanguage(java.lang.String language)

  Set the ISO-639 language code to distinguish different pages in application scope

  Parameters:
    `language` - The language code for this cache entry.

### setRefresh

    public void setRefresh(boolean refresh)

  This method allows the user to programatically decide whether the cached content should be refreshed immediately.

  Parameters:
    `refresh` - Whether or not to refresh this cache entry immediately.

### setMode

    public void setMode(java.lang.String mode)

  Setting this to `true` prevents the cache from writing any output to the response, however the JSP content is still cached as normal.

  Parameters:
    `mode` - The cache mode to use.

### setRefreshpolicyclass

    public void setRefreshpolicyclass(java.lang.String refreshPolicyClass)

  Class used to handle the refresh policy logic

### setRefreshpolicyparam

    public void setRefreshpolicyparam(java.lang.String refreshPolicyParam)

  Parameters that will be passed to the init method of the refresh policy instance.

### setScope

    public void setScope(java.lang.String scope)

  Set the scope of this cache.

  Parameters:
    `scope` - The scope of this cache. Either "application" (default) or "session".

### setTime

    public void setTime(int time)

  Set the time this cache entry will be cached for (in seconds)

  Parameters:
    `time` - The time to cache this content (in seconds). Passing in a time of zero will turn off the caching. A negative value for the time will result in the cached content never expiring (ie, the cached content will always be served if it is present)

### setUseBody

    public void setUseBody(boolean useBody)

  This controls whether or not the body of the tag is evaluated or used.

  It is most often called by the <UseCached /> tag to tell this tag to use the cached content.

  Parameters:
    `useBody` - Whether or not to use the cached content.
  See Also:
    `UseCachedTag`

### doAfterBody

    public int doAfterBody()
                    throws javax.servlet.jsp.JspTagException

  After the cache body, either update the cache, serve new cached content or indicate an error.

  Specified by:
    `doAfterBody` in interface `javax.servlet.jsp.tagext.IterationTag`
  Returns:
    The standard BodyTag return.
  Throws:
    `javax.servlet.jsp.JspTagException` - The standard exception thrown.

### doCatch

    public void doCatch(java.lang.Throwable throwable)
                 throws java.lang.Throwable

  Specified by:
    `doCatch` in interface `javax.servlet.jsp.tagext.TryCatchFinally`
  Throws:
    `java.lang.Throwable`

### doEndTag

    public int doEndTag()
                 throws javax.servlet.jsp.JspTagException

  The end tag - clean up variables used.

  Specified by:
    `doEndTag` in interface `javax.servlet.jsp.tagext.Tag`
  Returns:
    The standard BodyTag return.
  Throws:
    `javax.servlet.jsp.JspTagException` - The standard exception thrown.

### doFinally

    public void doFinally()

  Specified by:
    `doFinally` in interface `javax.servlet.jsp.tagext.TryCatchFinally`

### doStartTag

    public int doStartTag()
                   throws javax.servlet.jsp.JspTagException

  The start of the tag.

  Grabs the administrator, the cache, the specific cache entry, then decides whether to refresh.

  If no refresh is needed, this serves the cached content directly.

  Specified by:
    `doStartTag` in interface `javax.servlet.jsp.tagext.Tag`
  Returns:
    The standard doStartTag() return.
  Throws:
    `javax.servlet.jsp.JspTagException` - The standard exception thrown.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| See www.opensymphony.com for more information.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD