org.apache.shale.clay.config.beans
Class ConfigDefinitionsWatchdogFilter

java.lang.Object
  extended by org.apache.shale.clay.config.beans.ConfigDefinitionsWatchdogFilter
All Implemented Interfaces:
Command

public class ConfigDefinitionsWatchdogFilter
extends Object
implements Command

This is the timing mechanism for looking for modified Clay templates and configuration files. This is a preprocess filter chains command that should only be used in the development environment.


Field Summary
 
Fields inherited from interface org.apache.commons.chain.Command
CONTINUE_PROCESSING, PROCESSING_COMPLETE
 
Constructor Summary
ConfigDefinitionsWatchdogFilter()
           
 
Method Summary
protected  void accept(Context context)
          Trigger reloading of the Clay's xml configuration files if the org.apache.shale.clay.AUTO_RELOAD_CONFIG_FILES init parameter is set to true in the web.xml.
 boolean execute(Context context)
          Perform the matching algorithm against the value returned by the value() method.
 String getIncludes()
           
protected  boolean matches(String expr, Pattern[] patterns, boolean unrestricted)
          Match the specified expression against the specified precompiled patterns.
 void setIncludes(String includes)
          Set the comma-delimited regular expression patterns to include remote host names that match, if any; or null for no restrictions.
protected  String value(Context context)
          Return the servlet path (if any) concatenated with the path info (if any) for this request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigDefinitionsWatchdogFilter

public ConfigDefinitionsWatchdogFilter()
Method Detail

getIncludes

public String getIncludes()
Returns:
Return the comma-delimited regular expresson patterns to include remote host names that match, if any; otherwise, return null.

setIncludes

public void setIncludes(String includes)

Set the comma-delimited regular expression patterns to include remote host names that match, if any; or null for no restrictions.

Parameters:
includes - New include pattern(s)

value

protected String value(Context context)

Return the servlet path (if any) concatenated with the path info (if any) for this request.

Parameters:
context - Context for the current request
Returns:
servletPath and pathInfo

execute

public boolean execute(Context context)
                throws Exception

Perform the matching algorithm against the value returned by the value() method. If the value matches() the includes pattern list, the Clay configuration files are checked for changes and reloaded.

Specified by:
execute in interface Command
Parameters:
context - ShaleWebContext for this request
Returns:
true if the chain is done
Throws:
Exception - thrown back to the calling command

accept

protected void accept(Context context)
               throws Exception

Trigger reloading of the Clay's xml configuration files if the org.apache.shale.clay.AUTO_RELOAD_CONFIG_FILES init parameter is set to true in the web.xml. The HTML templates are re-cashed on-demand due to their atomicity. The XML configuration files are shared by all Clay view composition mechanisms so all files must be reloaded if a change is made.

Parameters:
context - Context for the current request
Throws:
Exception - thrown back to the caller

matches

protected boolean matches(String expr,
                          Pattern[] patterns,
                          boolean unrestricted)

Match the specified expression against the specified precompiled patterns. If there are no patterns, return the specified unrestricted return value; otherwise, return true if the expression matches one of the patterns, or false otherwise.

Parameters:
expr - Expression to be tested
patterns - Array of Pattern to be tested against
unrestricted - Result to be returned if there are no matches
Returns:
true if a match is found


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.