You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2007/04/24 19:24:10 UTC
svn commit: r532017 - in /velocity/tools/branches/2.x: ./
src/main/java/org/apache/velocity/tools/config/
src/main/java/org/apache/velocity/tools/generic/
src/main/java/org/apache/velocity/tools/struts/
src/main/java/org/apache/velocity/tools/view/
Author: nbubna
Date: Tue Apr 24 10:24:09 2007
New Revision: 532017
URL: http://svn.apache.org/viewvc?view=rev&rev=532017
Log:
make it trivial to create default config/factory
Added:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/tools.xml (with props)
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/tools.xml (with props)
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools.xml (with props)
Modified:
velocity/tools/branches/2.x/build.xml
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java
Modified: velocity/tools/branches/2.x/build.xml
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/build.xml?view=diff&rev=532017&r1=532016&r2=532017
==============================================================================
--- velocity/tools/branches/2.x/build.xml (original)
+++ velocity/tools/branches/2.x/build.xml Tue Apr 24 10:24:09 2007
@@ -156,6 +156,7 @@
<copy todir="${classes.dir}" filtering="yes">
<fileset dir="${classes.src}">
<include name="**/*.properties"/>
+ <include name="**/*.xml"/>
</fileset>
</copy>
</target>
@@ -178,7 +179,10 @@
<copy todir="${classes.dir}" filtering="yes">
<fileset dir="${classes.src}">
- <include name="**/*.properties"/>
+ <include name="**/generic/*.properties"/>
+ <include name="**/generic/*.xml"/>
+ <include name="**/view/*.properties"/>
+ <include name="**/view/*.xml"/>
</fileset>
</copy>
</target>
@@ -199,6 +203,13 @@
<exclude name="**/struts/**"/>
<exclude name="**/view/**"/>
</javac>
+
+ <copy todir="${classes.dir}" filtering="yes">
+ <fileset dir="${classes.src}">
+ <include name="**/generic/*.properties"/>
+ <include name="**/generic/*.xml"/>
+ </fileset>
+ </copy>
</target>
Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java?view=diff&rev=532017&r1=532016&r2=532017
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java (original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java Tue Apr 24 10:24:09 2007
@@ -33,6 +33,13 @@
public class FactoryConfiguration
extends CompoundConfiguration<ToolboxConfiguration>
{
+ public static final String GENERIC_CONFIGURATION_PATH =
+ "/org/apache/velocity/tools/generic/tools.xml";
+ public static final String VIEW_CONFIGURATION_PATH =
+ "/org/apache/velocity/tools/view/tools.xml";
+ public static final String STRUTS_CONFIGURATION_PATH =
+ "/org/apache/velocity/tools/struts/tools.xml";
+
private List<Data> data = new ArrayList<Data>();
@@ -101,4 +108,33 @@
factory.configure(this);
return factory;
}
+
+ /**
+ * Returns the "default" {@link FactoryConfiguration}. This includes
+ * all the standard tools developed by this project and available in
+ * the jar being used. In other words, if the velocity-tools-generic-2.x.jar
+ * is being used, then only the generic tools will be included. If
+ * the velocity-tools-struts-2.x.jar is being used, then all VelocityTools
+ * will be available. This also means that subclasses in the larger jars
+ * will override their superclasses. So, if you are using the VelocityStruts
+ * jar, then you $link reference will be a StrutsLinkTool. If you are using
+ * the VelocityView jar, it will be a standard LinkTool.
+ */
+ public static FactoryConfiguration getDefault()
+ {
+ FileFactoryConfiguration config = new XmlFactoryConfiguration();
+ config.read(GENERIC_CONFIGURATION_PATH);
+ // view tools and struts tools may not be available
+ config.read(VIEW_CONFIGURATION_PATH, false);
+ config.read(STRUTS_CONFIGURATION_PATH, false);
+ return config;
+ }
+
+ public static ToolboxFactory createDefaultFactory()
+ {
+ ToolboxFactory factory = new ToolboxFactory();
+ factory.configure(getDefault());
+ return factory;
+ }
+
}
Added: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/tools.xml
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/tools.xml?view=auto&rev=532017
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/tools.xml (added)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/tools.xml Tue Apr 24 10:24:09 2007
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<tools>
+ <data type="number" key="TOOLS_VERSION" value="2.0"/>
+ <data type="boolean" key="GENERIC_TOOLS_AVAILABLE" value="true"/>
+ <toolbox scope="application">
+ <tool class="org.apache.velocity.tools.generic.AlternatorTool"/>
+ <tool class="org.apache.velocity.tools.generic.ComparisonDateTool"/>
+ <tool class="org.apache.velocity.tools.generic.EscapeTool"/>
+ <tool class="org.apache.velocity.tools.generic.IteratorTool"/>
+ <tool class="org.apache.velocity.tools.generic.ListTool"/>
+ <tool class="org.apache.velocity.tools.generic.MathTool"/>
+ <tool class="org.apache.velocity.tools.generic.NumberTool"/>
+ <tool class="org.apache.velocity.tools.generic.RenderTool"/>
+ <tool class="org.apache.velocity.tools.generic.ResourceTool"/>
+ <tool class="org.apache.velocity.tools.generic.SortTool"/>
+ <!--
+ This is not useful in its default form.
+ <tool class="org.apache.velocity.tools.generic.ValueParser"/>
+ -->
+ </toolbox>
+</tools>
Propchange: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/tools.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/tools.xml
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/tools.xml?view=auto&rev=532017
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/tools.xml (added)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/tools.xml Tue Apr 24 10:24:09 2007
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<tools>
+ <data type="boolean" key="VIEW_TOOLS_AVAILABLE" value="true"/>
+ <toolbox scope="request">
+ <tool class="org.apache.velocity.tools.struts.ActionMessagesTool"/>
+ <tool class="org.apache.velocity.tools.struts.ErrorsTool"/>
+ <tool class="org.apache.velocity.tools.struts.FormTool"/>
+ <tool class="org.apache.velocity.tools.struts.MessageTool"/>
+ <tool class="org.apache.velocity.tools.struts.StrutsLinkTool"/>
+ <tool class="org.apache.velocity.tools.struts.TilesTool"/>
+ <tool class="org.apache.velocity.tools.struts.ValidatorTool"/>
+ <!--
+ This tool will not work without special configuration.
+ <tool class="org.apache.velocity.tools.struts.SecureLinkTool"/>
+ -->
+ </toolbox>
+</tools>
Propchange: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/tools.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools.xml
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools.xml?view=auto&rev=532017
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools.xml (added)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools.xml Tue Apr 24 10:24:09 2007
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<tools>
+ <data type="boolean" key="VIEW_TOOLS_AVAILABLE" value="true"/>
+ <toolbox scope="request">
+ <tool class="org.apache.velocity.tools.view.tools.ContextTool"/>
+ <tool class="org.apache.velocity.tools.view.tools.CookieTool"/>
+ <tool class="org.apache.velocity.tools.view.tools.ImportTool"/>
+ <tool class="org.apache.velocity.tools.view.tools.LinkTool"/>
+ <tool class="org.apache.velocity.tools.view.tools.ParameterParser"/>
+ <tool class="org.apache.velocity.tools.view.tools.ViewRenderTool"/>
+ <tool class="org.apache.velocity.tools.view.tools.ViewResourceTool"/>
+ <!--
+ These are not directly useable.
+ <tool class="org.apache.velocity.tools.view.tools.AbstractPagerTool"/>
+ <tool class="org.apache.velocity.tools.view.tools.AbstractSearchTool"/>
+ -->
+ </toolbox>
+ <toolbox scope="session" createSession="false">
+ <tool class="org.apache.velocity.tools.view.tools.BrowserSnifferTool"/>
+ </toolbox>
+</tools>
Propchange: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools.xml
------------------------------------------------------------------------------
svn:eol-style = native