Commits

Anonymous committed 1513754

CACHE-215 Setting CacheFilter parameters runtime
CACHE-99 Use lazy initialization in cache filter in order to ease spring integration

Comments (0)

Files changed (2)

src/java/com/opensymphony/oscache/web/filter/CacheFilter.java

  *
  * It also gives great programatic control over refreshing, flushing and updating the cache.<p>
  *
- * @author <a href="mailto:sergek@lokitech.com">Serge Knystautas</a>
- * @author <a href="mailto:mike@atlassian.com">Mike Cannon-Brookes</a>
- * @author <a href="mailto:ltorunski@t-online.de">Lars Torunski</a>
+ * @author <a href="mailto:sergek [ AT ] lokitech.com">Serge Knystautas</a>
+ * @author <a href="mailto:mike [ AT ] atlassian.com">Mike Cannon-Brookes</a>
+ * @author <a href="mailto:ltorunski [ AT ] t-online.de">Lars Torunski</a>
  * @version $Revision$
  */
 public class CacheFilter implements Filter, ICacheKeyProvider, ICacheGroupsProvider {
      * <li><b>oscache-properties-file</b> - the properties file that contains the OSCache configuration
      * options to be used by the Cache that this Filter should use.</li>
      * 
-     * <li><b>time</b> - the default time (in seconds) to cache content for. The default
-     * value is 3600 seconds (one hour).</li>
-     * 
-     * <li><b>scope</b> - the default scope to cache content in. Acceptable values
-     * are <code>application</code> (default), <code>session</code>, <code>request</code> and
-     * <code>page</code>.</li>
-     * 
-     * <li><b>fragment</b> - defines if this filter handles fragments of a page. Acceptable values
-     * are <code>auto</code> (default) for auto detect, <code>no</code> and <code>yes</code>.</li>
-     * 
-     * <li><b>nocache</b> - defines which objects shouldn't be cached. Acceptable values
-     * are <code>off</code> (default) and <code>sessionIdInURL</code> if the session id is
-     * contained in the URL.</li>
-     * 
-     * <li><b>lastModified</b> - defines if the last modified header will be sent in the response. Acceptable values are
-     * <code>off</code> for don't sending the header, even it is set in the filter chain, 
-     * <code>on</code> for sending it if it is set in the filter chain and 
-     * <code>inital</code> (default) the last modified information will be set based on the current time and changes are allowed.</li>
-     * 
-     * <li><b>expires</b> - defines if the expires header will be sent in the response. Acceptable values are
-     * <code>off</code> for don't sending the header, even it is set in the filter chain, 
-     * <code>on</code> (default) for sending it if it is set in the filter chain and 
-     * <code>time</code> the expires information will be intialized based on the time parameter and creation time of the content.</li>
-     * 
-     * <li><b>max-age</b> - defines the cache control response header max-age. Acceptable values are
-     * <code>no init</code> for don't initializing the max-age cache control, 
-     * <code>time</code> the max-age information will be based on the time parameter and creation time of the content (expiration timestamp minus current timestamp), and</li>
-     * <code>[positive integer]</code> value constant in seconds to be set in every response, the default value is 60.</li>
-     * 
-     * <li><b>ICacheKeyProvider</b> - Class implementing the interface <code>ICacheKeyProvider</code>.
-     * A developer can implement a method which provides cache keys based on the request, 
-     * the servlect cache administrator and cache.</li>
-     * 
-     * <li><b>ICacheGroupsProvider</b> - Class implementing the interface <code>ICacheGroupsProvider</code>.
-     * A developer can implement a method which provides cache groups based on the request, 
-     * the servlect cache administrator and cache.</li>
-     *
-     * <li><b>EntryRefreshPolicy</b> - Class implementing the interface <code>EntryRefreshPolicy</code>.
-     * A developer can implement a class which provides a different custom cache invalidation policy for a specific cache entry.
-     * If not specified, the default policy is timed entry expiry as specified with the <b>time</b> parameter described above. 
-     * </li>
-     *
      * @param filterConfig The filter configuration
      */
     public void init(FilterConfig filterConfig) {
         // Get whatever settings we want...
         config = filterConfig;
 
-        log.info("OSCache: Initializing OSCache CacheFilter with filter name " + config.getFilterName());
+        log.info("OSCache: Initializing CacheFilter with filter name " + config.getFilterName());
 
         // setting the request filter to avoid reentrance with the same filter
         requestFiltered = REQUEST_FILTERED + config.getFilterName();
             	props = Config.loadProperties(propertiesfile, "CacheFilter with filter name '" + config.getFilterName()+ "'");
             }
         } catch (Exception e) {
-            log.info("OSCache: Could not get init parameter 'oscache-properties-file', using default.");
+            log.info("OSCache: Init parameter 'oscache-properties-file' not set, using default.");
         }
         admin = ServletCacheAdministrator.getInstance(config.getServletContext(), props);
 
         // filter parameter time
-        try {
-            time = Integer.parseInt(config.getInitParameter("time"));
-        } catch (Exception e) {
-            log.info("OSCache: Could not get init parameter 'time', defaulting to one hour.");
+        String timeParam = config.getInitParameter("time");
+        if (timeParam != null) {
+            try {
+                setTime(Integer.parseInt(timeParam));
+            } catch (NumberFormatException nfe) {
+                log.error("OSCache: Unexpected value for the init parameter 'time', defaulting to one hour. Message=" + nfe.getMessage());
+            }
         }
         
-        // setting the refresh period for this cache filter
-        expiresRefreshPolicy = new ExpiresRefreshPolicy(time);
-
         // filter parameter scope
-        try {
-            String scopeString = config.getInitParameter("scope");
-
-            if (scopeString.equals("session")) {
-                cacheScope = PageContext.SESSION_SCOPE;
-            } else if (scopeString.equals("application")) {
-                cacheScope = PageContext.APPLICATION_SCOPE;
-            } else if (scopeString.equals("request")) {
-                cacheScope = PageContext.REQUEST_SCOPE;
-            } else if (scopeString.equals("page")) {
-                cacheScope = PageContext.PAGE_SCOPE;
+        String scopeParam = config.getInitParameter("scope");
+        if (scopeParam != null) {
+            if ("session".equalsIgnoreCase(scopeParam)) {
+                setCacheScope(PageContext.SESSION_SCOPE);
+            } else if ("application".equalsIgnoreCase(scopeParam)) {
+                setCacheScope(PageContext.APPLICATION_SCOPE);
+            } else {
+                log.error("OSCache: Wrong value '" + scopeParam + "' for init parameter 'scope', defaulting to 'application'.");
             }
-        } catch (Exception e) {
-            log.info("OSCache: Could not get init parameter 'scope', defaulting to 'application'.");
+            
         }
 
         // filter parameter cron
-        cron = config.getInitParameter("cron");
+        setCron(config.getInitParameter("cron"));
 
         // filter parameter fragment
-        try {
-            String fragmentString = config.getInitParameter("fragment");
-            
-            if (fragmentString.equals("no")) {
-                fragment = FRAGMENT_NO;
-            } else if (fragmentString.equals("yes")) {
-                fragment = FRAGMENT_YES;
-            } else if (fragmentString.equalsIgnoreCase("auto")) {
-                fragment = FRAGMENT_AUTODETECT;
+        String fragmentParam = config.getInitParameter("fragment");
+        if (fragmentParam != null) {
+            if ("no".equalsIgnoreCase(fragmentParam)) {
+                setFragment(FRAGMENT_NO);
+            } else if ("yes".equalsIgnoreCase(fragmentParam)) {
+                setFragment(FRAGMENT_YES);
+            } else if ("auto".equalsIgnoreCase(fragmentParam)) {
+                setFragment(FRAGMENT_AUTODETECT);
+            } else {
+                log.error("OSCache: Wrong value '" + fragmentParam + "' for init parameter 'fragment', defaulting to 'auto detect'.");
             }
-        } catch (Exception e) {
-            log.info("OSCache: Could not get init parameter 'fragment', defaulting to 'auto detect'.");
         }
         
         // filter parameter nocache
-        try {
-            String nocacheString = config.getInitParameter("nocache");
-            
-            if (nocacheString.equals("off")) {
+        String nocacheParam = config.getInitParameter("nocache");
+        if (nocacheParam != null) {
+            if ("off".equalsIgnoreCase(nocacheParam)) {
                 nocache = NOCACHE_OFF;
-            } else if (nocacheString.equalsIgnoreCase("sessionIdInURL")) {
+            } else if ("sessionIdInURL".equalsIgnoreCase(nocacheParam)) {
                 nocache = NOCACHE_SESSION_ID_IN_URL;
-            } 
-        } catch (Exception e) {
-            log.info("OSCache: Could not get init parameter 'nocache', defaulting to 'off'.");
+            } else {
+                log.error("OSCache: Wrong value '" + nocacheParam + "' for init parameter 'nocache', defaulting to 'off'.");
+            }
         }
 
         // filter parameter last modified
-        try {
-            String lastModifiedString = config.getInitParameter("lastModified");
-            
-            if (lastModifiedString.equals("off")) {
+        String lastModifiedParam = config.getInitParameter("lastModified");
+        if (lastModifiedParam != null) {
+            if ("off".equalsIgnoreCase(lastModifiedParam)) {
                 lastModified = LAST_MODIFIED_OFF;
-            } else if (lastModifiedString.equals("on")) {
+            } else if ("on".equalsIgnoreCase(lastModifiedParam)) {
                 lastModified = LAST_MODIFIED_ON;
-            } else if (lastModifiedString.equalsIgnoreCase("initial")) {
+            } else if ("initial".equalsIgnoreCase(lastModifiedParam)) {
                 lastModified = LAST_MODIFIED_INITIAL;
-            } 
-        } catch (Exception e) {
-            log.info("OSCache: Could not get init parameter 'lastModified', defaulting to 'initial'.");
+            } else {
+                log.error("OSCache: Wrong value '" + lastModifiedParam + "' for init parameter 'lastModified', defaulting to 'initial'.");
+            }
         }
         
         // filter parameter expires
-        try {
-            String expiresString = config.getInitParameter("expires");
-            
-            if (expiresString.equals("off")) {
-                expires = EXPIRES_OFF;
-            } else if (expiresString.equals("on")) {
-                expires = EXPIRES_ON;
-            } else if (expiresString.equalsIgnoreCase("time")) {
-                expires = EXPIRES_TIME;
-            } 
-        } catch (Exception e) {
-            log.info("OSCache: Could not get init parameter 'expires', defaulting to 'on'.");
+        String expiresParam = config.getInitParameter("expires");
+        if (expiresParam != null) {
+            if ("off".equalsIgnoreCase(expiresParam)) {
+                setExpires(EXPIRES_OFF);
+            } else if ("on".equalsIgnoreCase(expiresParam)) {
+                setExpires(EXPIRES_ON);
+            } else if ("time".equalsIgnoreCase(expiresParam)) {
+                setExpires(EXPIRES_TIME);
+            } else {
+                log.error("OSCache: Wrong value '" + expiresParam + "' for init parameter 'expires', defaulting to 'on'.");
+            }
         }
 
         // filter parameter Cache-Control
-        try {
-            String cacheControlMaxAgeString = config.getInitParameter("max-age");
-            
-            if (cacheControlMaxAgeString.equals("no init")) {
-            	cacheControlMaxAge = MAX_AGE_NO_INIT;
-            } else if (cacheControlMaxAgeString.equals("time")) {
-            	cacheControlMaxAge = MAX_AGE_TIME;
+        String cacheControlMaxAgeParam = config.getInitParameter("max-age");
+        if (cacheControlMaxAgeParam != null) {
+            if (cacheControlMaxAgeParam.equalsIgnoreCase("no init")) {
+                setCacheControlMaxAge(MAX_AGE_NO_INIT);
+            } else if (cacheControlMaxAgeParam.equalsIgnoreCase("time")) {
+                setCacheControlMaxAge(MAX_AGE_TIME);
             } else {
-            	cacheControlMaxAge = Long.parseLong(cacheControlMaxAgeString);
-            	if (cacheControlMaxAge >= 0) {
-            		// declare the cache control as a constant
-            		cacheControlMaxAge = - cacheControlMaxAge;
-            	} else {
-                    log.warn("OSCache: Init parameter 'max-age' must be at least a positive integer, defaulting to 'time'. ");
-                	cacheControlMaxAge = 60;
-            	}
+                try {
+                    setCacheControlMaxAge(Long.parseLong(cacheControlMaxAgeParam));
+                } catch (NumberFormatException nfe) {
+                    log.error("OSCache: Unexpected value for the init parameter 'max-age', defaulting to '60'. Message=" + nfe.getMessage());
+                }
             }
-        } catch (Exception e) {
-            log.info("OSCache: Could not get init parameter 'max-age', defaulting to 'time'.");
         }
 
         // filter parameter ICacheKeyProvider
-        ICacheKeyProvider cacheKeyProvider = (ICacheKeyProvider)instantiateFromInitParam("ICacheKeyProvider", ICacheKeyProvider.class, this.getClass().getName());
-        if (cacheKeyProvider != null) {
-            this.cacheKeyProvider = cacheKeyProvider;
+        ICacheKeyProvider cacheKeyProviderParam = (ICacheKeyProvider)instantiateFromInitParam("ICacheKeyProvider", ICacheKeyProvider.class, this.getClass().getName());
+        if (cacheKeyProviderParam != null) {
+            setCacheKeyProvider(cacheKeyProviderParam);
         }
 
         // filter parameter ICacheGroupsProvider
-        ICacheGroupsProvider cacheGroupsProvider = (ICacheGroupsProvider)instantiateFromInitParam("ICacheGroupsProvider", ICacheGroupsProvider.class, this.getClass().getName());
-        if (cacheGroupsProvider != null) {
-            this.cacheGroupsProvider = cacheGroupsProvider;
+        ICacheGroupsProvider cacheGroupsProviderParam = (ICacheGroupsProvider)instantiateFromInitParam("ICacheGroupsProvider", ICacheGroupsProvider.class, this.getClass().getName());
+        if (cacheGroupsProviderParam != null) {
+            setCacheGroupsProvider(cacheGroupsProviderParam);
         }
         
         // filter parameter EntryRefreshPolicy
-        EntryRefreshPolicy expiresRefreshPolicy = (EntryRefreshPolicy)instantiateFromInitParam("EntryRefreshPolicy", EntryRefreshPolicy.class, this.expiresRefreshPolicy.getClass().getName());
-        if (expiresRefreshPolicy != null) {
-            this.expiresRefreshPolicy = expiresRefreshPolicy;
+        EntryRefreshPolicy expiresRefreshPolicyParam = (EntryRefreshPolicy)instantiateFromInitParam("EntryRefreshPolicy", EntryRefreshPolicy.class, ExpiresRefreshPolicy.class.getName());
+        if (expiresRefreshPolicyParam != null) {
+            setExpiresRefreshPolicy(expiresRefreshPolicyParam);
+        } else {
+            // setting the refresh period for this cache filter
+            setExpiresRefreshPolicy(new ExpiresRefreshPolicy(time));
         }
     }
 
-    private Object instantiateFromInitParam(String classInitParam, Class interfaceClass, String defaultClassName) {
+    private Object instantiateFromInitParam(String classInitParam, Class interfaceClass, String defaultObjectName) {
 		String className = config.getInitParameter(classInitParam);
-		if (className == null) {
-			log.info("OSCache: Could not get init parameter '" + classInitParam + "', defaulting to " + defaultClassName + ".");
-			return null;
-		} else {
-			try {
-				Class clazz = Class.forName(className);
-				if (!interfaceClass.isAssignableFrom(clazz)) {
-					log.error("OSCache: Specified class '" + className + "' does not implement" + interfaceClass.getName() + ". Using default " + defaultClassName + ".");
-					return null;
-				} else {
-					return clazz.newInstance();
-				}
-			} catch (ClassNotFoundException e) {
-				log.error("OSCache: Class '" + className + "' not found. Defaulting to " + defaultClassName + ".", e);
-			} catch (InstantiationException e) {
-				log.error("OSCache: Class '" + className + "' could not be instantiated because it is not a concrete class. Using default class " + defaultClassName + ".", e);
-			} catch (IllegalAccessException e) {
-				log.error("OSCache: Class '"+ className+ "' could not be instantiated because it is not public. Using default class " + defaultClassName + ".", e);
-			}
-			return null;
+		if (className != null) {
+            try {
+                Class clazz = Class.forName(className);
+                if (!interfaceClass.isAssignableFrom(clazz)) {
+                    log.error("OSCache: Specified class '" + className + "' does not implement" + interfaceClass.getName() + ". Using default " + defaultObjectName + ".");
+                    return null;
+                } else {
+                    return clazz.newInstance();
+                }
+            } catch (ClassNotFoundException e) {
+                log.error("OSCache: Class '" + className + "' not found. Defaulting to " + defaultObjectName + ".", e);
+            } catch (InstantiationException e) {
+                log.error("OSCache: Class '" + className + "' could not be instantiated because it is not a concrete class. Using default object " + defaultObjectName + ".", e);
+            } catch (IllegalAccessException e) {
+                log.error("OSCache: Class '"+ className+ "' could not be instantiated because it is not public. Using default object " + defaultObjectName + ".", e);
+            }
 		}
+        return null;
 	}
     
     /**
         return  (acceptEncoding != null) && (acceptEncoding.indexOf("gzip") != -1);
     }
 
+    // ---------------------------------
+    // --- getter and setter methods ---
+    // ---------------------------------
+    
+    /**
+     * @return the max-age of the cache control
+     */
+    public long getCacheControlMaxAge() {
+        if ((cacheControlMaxAge == MAX_AGE_NO_INIT) || (cacheControlMaxAge == MAX_AGE_TIME)) {
+            return cacheControlMaxAge;
+        }
+        return - cacheControlMaxAge;
+    }
+
+    /**
+     * <b>max-age</b> - defines the cache control response header max-age. Acceptable values are
+     * <code>MAX_AGE_NO_INIT</code> for don't initializing the max-age cache control, 
+     * <code>MAX_AGE_TIME</code> the max-age information will be based on the time parameter and creation time of the content (expiration timestamp minus current timestamp), and
+     * <code>[positive integer]</code> value constant in seconds to be set in every response, the default value is 60.
+     * 
+     * @param cacheControlMaxAge the cacheControlMaxAge to set
+     */
+    public void setCacheControlMaxAge(long cacheControlMaxAge) {
+        if ((cacheControlMaxAge == MAX_AGE_NO_INIT) || (cacheControlMaxAge == MAX_AGE_TIME)) {
+            this.cacheControlMaxAge = cacheControlMaxAge;
+        } else if (cacheControlMaxAge >= 0) {
+            // declare the cache control as a constant
+            // TODO check if this value can be stored as a positive long without changing it
+            this.cacheControlMaxAge = - cacheControlMaxAge;
+        } else {
+            log.warn("OSCache: 'max-age' must be at least a positive integer, defaulting to '60'. ");
+            this.cacheControlMaxAge = -60;
+        }
+    }
+
+    /**
+     * @return the cacheGroupsProvider
+     */
+    public ICacheGroupsProvider getCacheGroupsProvider() {
+        return cacheGroupsProvider;
+    }
+
+    /**
+     * <b>ICacheGroupsProvider</b> - Class implementing the interface <code>ICacheGroupsProvider</code>.
+     * A developer can implement a method which provides cache groups based on the request, 
+     * the servlect cache administrator and cache. The parameter has to be not <code>null</code>.
+     *
+     * @param cacheGroupsProvider the cacheGroupsProvider to set
+     */
+    public void setCacheGroupsProvider(ICacheGroupsProvider cacheGroupsProvider) {
+        if (cacheGroupsProvider == null) throw new IllegalArgumentException("The ICacheGroupsProvider is null.");
+        this.cacheGroupsProvider = cacheGroupsProvider;
+    }
+
+    /**
+     * @return the cacheKeyProvider
+     */
+    public ICacheKeyProvider getCacheKeyProvider() {
+        return cacheKeyProvider;
+    }
+
+    /**
+     * <b>ICacheKeyProvider</b> - Class implementing the interface <code>ICacheKeyProvider</code>.
+     * A developer can implement a method which provides cache keys based on the request, 
+     * the servlect cache administrator and cache. The parameter has to be not <code>null</code>.
+     * 
+     * @param cacheKeyProvider the cacheKeyProvider to set
+     */
+    public void setCacheKeyProvider(ICacheKeyProvider cacheKeyProvider) {
+        if (cacheKeyProvider == null) throw new IllegalArgumentException("The ICacheKeyProvider is null.");
+        this.cacheKeyProvider = cacheKeyProvider;
+    }
+
+    /**
+     * Returns PageContext.APPLICATION_SCOPE or PageContext.SESSION_SCOPE.
+     * @return the cache scope
+     */
+    public int getCacheScope() {
+        return cacheScope;
+    }
+
+    /**
+     * <b>scope</b> - the default scope to cache content. Acceptable values
+     * are <code>PageContext.APPLICATION_SCOPE</code> (default) and <code>PageContext.SESSION_SCOPE</code>.
+     * 
+     * @param cacheScope the cacheScope to set
+     */
+    public void setCacheScope(int cacheScope) {
+        if ((cacheScope != PageContext.APPLICATION_SCOPE) && (cacheScope != PageContext.SESSION_SCOPE))
+            throw new IllegalArgumentException("Acceptable values for cache scope are PageContext.APPLICATION_SCOPE or PageContext.SESSION_SCOPE");
+        this.cacheScope = cacheScope;
+    }
+
+    /**
+     * @return the cron
+     */
+    public String getCron() {
+        return cron;
+    }
+
+    /**
+     * <b>cron</b> - defines an expression that determines when the page content will expire.
+     * This allows content to be expired at particular dates and/or times, rather than once 
+     * a cache entry reaches a certain age.
+     * 
+     * @param cron the cron to set
+     */
+    public void setCron(String cron) {
+        this.cron = cron;
+    }
+
+    /**
+     * @return the expires header
+     */
+    public long getExpires() {
+        return expires;
+    }
+
+    /**
+     * <b>expires</b> - defines if the expires header will be sent in the response. Acceptable values are
+     * <code>EXPIRES_OFF</code> for don't sending the header, even it is set in the filter chain, 
+     * <code>EXPIRES_ON</code> (default) for sending it if it is set in the filter chain and 
+     * <code>EXPIRES_TIME</code> the expires information will be intialized based on the time parameter and creation time of the content.
+     * 
+     * @param expires the expires to set
+     */
+    public void setExpires(long expires) {
+        if ((expires < EXPIRES_TIME) || (expires > EXPIRES_ON)) throw new IllegalArgumentException("Expires value out of range.");
+        this.expires = expires;
+    }
+
+    /**
+     * @return the expiresRefreshPolicy
+     */
+    public EntryRefreshPolicy getExpiresRefreshPolicy() {
+        return expiresRefreshPolicy;
+    }
+
+    /**
+     * <b>EntryRefreshPolicy</b> - Class implementing the interface <code>EntryRefreshPolicy</code>.
+     * A developer can implement a class which provides a different custom cache invalidation policy for a specific cache entry.
+     * If not specified, the default policy is timed entry expiry as specified with the <b>time</b> parameter described above. 
+     *
+     * @param expiresRefreshPolicy the expiresRefreshPolicy to set
+     */
+    public void setExpiresRefreshPolicy(EntryRefreshPolicy expiresRefreshPolicy) {
+        if (expiresRefreshPolicy == null) throw new IllegalArgumentException("The EntryRefreshPolicy is null.");
+        this.expiresRefreshPolicy = expiresRefreshPolicy;
+    }
+
+    /**
+     * @return the fragment
+     */
+    public int getFragment() {
+        return fragment;
+    }
+
+    /**
+     * <b>fragment</b> - defines if this filter handles fragments of a page. Acceptable values
+     * are <code>FRAGMENT_AUTODETECT</code> (default) for auto detect, <code>FRAGMENT_NO</code> and <code>FRAGMENT_YES</code>.
+     * 
+     * @param fragment the fragment to set
+     */
+    public void setFragment(int fragment) {
+        if ((fragment < FRAGMENT_AUTODETECT) || (fragment > FRAGMENT_YES)) throw new IllegalArgumentException("Fragment value out of range.");
+        this.fragment = fragment;
+    }
+
+    /**
+     * @return the lastModified
+     */
+    public long getLastModified() {
+        return lastModified;
+    }
+
+    /**
+     * <b>lastModified</b> - defines if the last modified header will be sent in the response. Acceptable values are
+     * <code>LAST_MODIFIED_OFF</code> for don't sending the header, even it is set in the filter chain, 
+     * <code>LAST_MODIFIED_ON</code> for sending it if it is set in the filter chain and 
+     * <code>LAST_MODIFIED_INITIAL</code> (default) the last modified information will be set based on the current time and changes are allowed.
+     * 
+     * @param lastModified the lastModified to set
+     */
+    public void setLastModified(long lastModified) {
+        if ((lastModified < LAST_MODIFIED_INITIAL) || (lastModified > LAST_MODIFIED_ON)) throw new IllegalArgumentException("LastModified value out of range.");
+        this.lastModified = lastModified;
+    }
+
+    /**
+     * @return the nocache
+     */
+    public int getNocache() {
+        return nocache;
+    }
+
+    /**
+     * <b>nocache</b> - defines which objects shouldn't be cached. Acceptable values
+     * are <code>NOCACHE_OFF</code> (default) and <code>NOCACHE_SESSION_ID_IN_URL</code> if the session id is
+     * contained in the URL.
+     * 
+     * @param nocache the nocache to set
+     */
+    public void setNocache(int nocache) {
+        if ((nocache < NOCACHE_OFF) || (nocache > NOCACHE_SESSION_ID_IN_URL)) throw new IllegalArgumentException("Nocache value out of range.");
+        this.nocache = nocache;
+    }
+
+    /**
+     * @return the time
+     */
+    public int getTime() {
+        return time;
+    }
+
+    /**
+     * <b>time</b> - the default time (in seconds) to cache content for. The default
+     * value is 3600 seconds (one hour). Specifying -1 (indefinite expiry) as the cache 
+     * time will ensure a content does not become stale until it is either explicitly 
+     * flushed or the expires refresh policy causes the entry to expire.
+     * 
+     * @param time the time to set
+     */
+    public void setTime(int time) {
+        this.time = time;
+        // check if ExpiresRefreshPolicy has to be reset
+        if (expiresRefreshPolicy instanceof ExpiresRefreshPolicy) {
+            ((ExpiresRefreshPolicy) expiresRefreshPolicy).setRefreshPeriod(time);
+        }
+    }
+    
+    // TODO: check if getter/setter for oscache-properties-file is possible
+    
 }

src/java/com/opensymphony/oscache/web/filter/ExpiresRefreshPolicy.java

  * This is useful when expires header are used in the response.
  *
  * @version $Revision$
- * @author <a href="mailto:ltorunski@t-online.de">Lars Torunski</a>
+ * @author <a href="mailto:ltorunski [ AT ] t-online.de">Lars Torunski</a>
  */
 public class ExpiresRefreshPolicy implements EntryRefreshPolicy {
     
         }
         
     }
+
+    /**
+     * @return the refreshPeriod in seconds
+     */
+    public long getRefreshPeriod() {
+        return refreshPeriod / 1000;
+    }
+
+    /**
+     * @param refreshPeriod the refresh period in seconds
+     */
+    public void setRefreshPeriod(long refreshPeriod) {
+        this.refreshPeriod = refreshPeriod * 1000L;
+    }
     
 }