Author: nbubna Date: Fri Apr 27 20:19:27 2007 New Revision: 533278 URL: http://svn.apache.org/viewvc?view=rev&rev=533278 Log: add a rule that sets a property indicating that an old toolbox.xml format was used
Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/OldXmlFactoryConfigurationRuleSet.java Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/OldXmlFactoryConfigurationRuleSet.java URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/OldXmlFactoryConfigurationRuleSet.java?view=diff&rev=533278&r1=533277&r2=533278 ============================================================================== --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/OldXmlFactoryConfigurationRuleSet.java (original) +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/OldXmlFactoryConfigurationRuleSet.java Fri Apr 27 20:19:27 2007 @@ -32,7 +32,7 @@ * @deprecated This is provided merely for 1.x compatibility. * @version $Id: OldXmlFactoryConfigurationRuleSet.java 511959 2007-02-26 19:24:39Z nbubna $ */ -class OldXmlFactoryConfigurationRuleSet extends RuleSetBase +public class OldXmlFactoryConfigurationRuleSet extends RuleSetBase { public void addRuleInstances(Digester digester) { @@ -40,6 +40,7 @@ digester.addRule("toolbox/xhtml", new XhtmlRule()); digester.addObjectCreate("toolbox", ToolboxConfiguration.class); + digester.addRule("toolbox", new DeprecationRule()); digester.addSetNext("toolbox", "addToolbox"); digester.addObjectCreate("toolbox/tool", ToolConfiguration.class); @@ -57,6 +58,19 @@ digester.addRule("toolbox/data", new SetNextDataRule()); } + protected class DeprecationRule extends Rule + { + public void begin(String ns, String ln, Attributes attributes) + throws Exception + { + // add a property to the FactoryConfiguration that + // will trigger a deprecation warning in the logs + FactoryConfiguration factory = + (FactoryConfiguration)digester.getRoot(); + factory.setProperty("oldXmlWarning", true); + } + } + protected class ScopeRule extends Rule { @@ -140,10 +154,10 @@ { public void setBoolean(FactoryConfiguration factory, Boolean b) { - // for templates - factory.setProperty("XHTML", b); // for tools factory.setProperty("Xhtml", b); + // for templates + factory.setProperty("XHTML", b); } }