FileDocCategorySizeDatePackage
FlushTag.javaAPI DocGlassfish v2 API5823Fri May 04 22:35:28 BST 2007com.sun.appserv.web.taglibs.cache

FlushTag

public class FlushTag extends TagSupport
FlushTag is a JSP tag that is used with the CacheTag. The FlushTag allows you to invalidate a complete cache or a particular cache element identified by the key. Usage Example: <%@ taglib prefix="ias" uri="Sun ONE Application Server Tags" %>

Fields Summary
private String
_key
The key for the cache entry that needs to be flushed.
private int
_scope
This specifies the scope of the cache that needs to be flushed.
private static Logger
_logger
The logger to use for logging ALL web container related messages.
private static boolean
_debugLog
This indicates whether debug logging is on or not
private static ResourceBundle
_rb
The resource bundle containing the localized message strings.
Constructors Summary
public FlushTag()
Default constructor that simply gets a handle to the web container subsystem's logger.


    // ---------------------------------------------------------------------
    // Constructor and initialization

                      
      
        super();
         if (_logger == null) {
             _logger = LogDomains.getLogger(LogDomains.PWC_LOGGER);
             _rb = _logger.getResourceBundle();
             _debugLog = _logger.isLoggable(Level.FINE);
         }
    
Methods Summary
public intdoEndTag()
doEndTag just resets all the valiables in case the tag is reused

throws
JspException the standard exception thrown
return
always returns EVAL_PAGE since we want the entire jsp evaluated

        _key = null;
        _scope = PageContext.APPLICATION_SCOPE;

        return EVAL_PAGE;
    
public intdoStartTag()
doStartTag is called when the flush tag is encountered. By the time this is called, the tag attributes are already set.

throws
JspException the standard exception thrown
return
SKIP_BODY since the tag should be empty

        // get the cache from the specified scope
        Cache cache = CacheUtil.getCache(pageContext, _scope);

        // generate the cache key using the user specified key.
   
        if (_key != null) {
            String key = CacheUtil.generateKey(_key, pageContext);

            // remove the entry for the key
            cache.remove(key);

            if (_debugLog)
                _logger.fine("FlushTag: clear ["+ key +"]");
        } else {
            // clear the entire cache
            cache.clear();

            if (_debugLog)
                _logger.fine("FlushTag: clear cache");
        }

        return SKIP_BODY;
    
public voidsetKey(java.lang.String key)
This is set a key for the cache element that needs to be cleared

        if (key != null && key.length() > 0)
            _key = key;
    
public voidsetScope(java.lang.String scope)
Sets the scope of the cache.

param
scope the scope of the cache
throws
IllegalArgumentException if the specified scope is different from request, session, and application

        _scope = CacheUtil.convertScope(scope);