WW-5049 Moves Velocity support into a dedicated plugin
diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml
index c0b9023..99bceb7 100644
--- a/apps/showcase/pom.xml
+++ b/apps/showcase/pom.xml
@@ -95,6 +95,11 @@
</dependency>
<dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-velocity-plugin</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
diff --git a/apps/showcase/src/main/resources/struts-tags-ui.xml b/apps/showcase/src/main/resources/struts-tags-ui.xml
index 69b9bda..13e33d6 100644
--- a/apps/showcase/src/main/resources/struts-tags-ui.xml
+++ b/apps/showcase/src/main/resources/struts-tags-ui.xml
@@ -24,7 +24,7 @@
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
- <package name="ui-tags" extends="struts-default" namespace="/tags/ui">
+ <package name="ui-tags" extends="velocity-default" namespace="/tags/ui">
<action name="example" class="org.apache.struts2.showcase.UITagExample">
<result>/WEB-INF/tags/ui/example.jsp</result>
<result name="input">/WEB-INF/tags/ui/example.jsp</result>
diff --git a/core/src/main/java/org/apache/struts2/StrutsConstants.java b/core/src/main/java/org/apache/struts2/StrutsConstants.java
index 3f9da83..2d12095 100644
--- a/core/src/main/java/org/apache/struts2/StrutsConstants.java
+++ b/core/src/main/java/org/apache/struts2/StrutsConstants.java
@@ -102,9 +102,6 @@
/** Maximum strong sizing for MruCacheStorage for freemarker */
public static final String STRUTS_FREEMARKER_MRU_MAX_STRONG_SIZE = "struts.freemarker.mru.max.strong.size";
-
- /** org.apache.struts2.views.velocity.VelocityManager implementation class */
- public static final String STRUTS_VELOCITY_MANAGER_CLASSNAME = "struts.velocity.manager.classname";
/** The Velocity configuration file path */
public static final String STRUTS_VELOCITY_CONFIGFILE = "struts.velocity.configfile";
diff --git a/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java b/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
index 0ebe8cd..1e976f0 100644
--- a/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
+++ b/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
@@ -67,7 +67,6 @@
import org.apache.struts2.util.ContentTypeMatcher;
import org.apache.struts2.views.freemarker.FreemarkerManager;
import org.apache.struts2.views.util.UrlHelper;
-import org.apache.struts2.views.velocity.VelocityManager;
/**
* Selects the implementations of key framework extension points, using the loaded
@@ -367,8 +366,6 @@
*/
public class DefaultBeanSelectionProvider extends AbstractBeanSelectionProvider {
- private static final Logger LOG = LogManager.getLogger(DefaultBeanSelectionProvider.class);
-
public void register(ContainerBuilder builder, LocatableProperties props) {
alias(ObjectFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY, builder, props);
alias(ActionFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY_ACTIONFACTORY, builder, props);
@@ -404,7 +401,6 @@
alias(ActionMapper.class, StrutsConstants.STRUTS_MAPPER_CLASS, builder, props);
alias(MultiPartRequest.class, StrutsConstants.STRUTS_MULTIPART_PARSER, builder, props, Scope.PROTOTYPE);
alias(FreemarkerManager.class, StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME, builder, props);
- alias(VelocityManager.class, StrutsConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME, builder, props);
alias(UrlRenderer.class, StrutsConstants.STRUTS_URL_RENDERER, builder, props);
alias(ActionValidatorManager.class, StrutsConstants.STRUTS_ACTIONVALIDATORMANAGER, builder, props);
alias(ValueStackFactory.class, StrutsConstants.STRUTS_VALUESTACKFACTORY, builder, props);
diff --git a/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java b/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
index d92ce00..904296f 100644
--- a/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
+++ b/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
@@ -185,7 +185,6 @@
map.put(StrutsConstants.STRUTS_FREEMARKER_TEMPLATES_CACHE_UPDATE_DELAY, freemarkerTemplatesCacheUpdateDelay);
map.put(StrutsConstants.STRUTS_FREEMARKER_BEANWRAPPER_CACHE, Objects.toString(freemarkerBeanwrapperCache, null));
map.put(StrutsConstants.STRUTS_FREEMARKER_MRU_MAX_STRONG_SIZE, Objects.toString(freemarkerMruMaxStrongSize, null));
- map.put(StrutsConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME, beanConfToString(velocityManagerClassname));
map.put(StrutsConstants.STRUTS_VELOCITY_CONFIGFILE, velocityConfigfile);
map.put(StrutsConstants.STRUTS_VELOCITY_TOOLBOXLOCATION, velocityToolboxlocation);
map.put(StrutsConstants.STRUTS_VELOCITY_CONTEXTS, StringUtils.join(velocityContexts, ','));
diff --git a/core/src/main/java/org/apache/struts2/views/DefaultTagLibrary.java b/core/src/main/java/org/apache/struts2/views/DefaultTagLibrary.java
index 5a01df3..cab6c40 100644
--- a/core/src/main/java/org/apache/struts2/views/DefaultTagLibrary.java
+++ b/core/src/main/java/org/apache/struts2/views/DefaultTagLibrary.java
@@ -18,55 +18,16 @@
*/
package org.apache.struts2.views;
-import java.util.Arrays;
-import java.util.List;
+import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.struts2.views.freemarker.tags.StrutsModels;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.struts2.views.freemarker.tags.StrutsModels;
-import org.apache.struts2.views.velocity.components.ActionDirective;
-import org.apache.struts2.views.velocity.components.ActionErrorDirective;
-import org.apache.struts2.views.velocity.components.ActionMessageDirective;
-import org.apache.struts2.views.velocity.components.AnchorDirective;
-import org.apache.struts2.views.velocity.components.BeanDirective;
-import org.apache.struts2.views.velocity.components.CheckBoxDirective;
-import org.apache.struts2.views.velocity.components.CheckBoxListDirective;
-import org.apache.struts2.views.velocity.components.ComboBoxDirective;
-import org.apache.struts2.views.velocity.components.ComponentDirective;
-import org.apache.struts2.views.velocity.components.DateDirective;
-import org.apache.struts2.views.velocity.components.DoubleSelectDirective;
-import org.apache.struts2.views.velocity.components.FieldErrorDirective;
-import org.apache.struts2.views.velocity.components.FileDirective;
-import org.apache.struts2.views.velocity.components.FormDirective;
-import org.apache.struts2.views.velocity.components.HeadDirective;
-import org.apache.struts2.views.velocity.components.HiddenDirective;
-import org.apache.struts2.views.velocity.components.I18nDirective;
-import org.apache.struts2.views.velocity.components.IncludeDirective;
-import org.apache.struts2.views.velocity.components.LabelDirective;
-import org.apache.struts2.views.velocity.components.OptionTransferSelectDirective;
-import org.apache.struts2.views.velocity.components.ParamDirective;
-import org.apache.struts2.views.velocity.components.PasswordDirective;
-import org.apache.struts2.views.velocity.components.PropertyDirective;
-import org.apache.struts2.views.velocity.components.PushDirective;
-import org.apache.struts2.views.velocity.components.RadioDirective;
-import org.apache.struts2.views.velocity.components.ResetDirective;
-import org.apache.struts2.views.velocity.components.SelectDirective;
-import org.apache.struts2.views.velocity.components.SetDirective;
-import org.apache.struts2.views.velocity.components.SubmitDirective;
-import org.apache.struts2.views.velocity.components.TextAreaDirective;
-import org.apache.struts2.views.velocity.components.TextDirective;
-import org.apache.struts2.views.velocity.components.TextFieldDirective;
-import org.apache.struts2.views.velocity.components.TokenDirective;
-import org.apache.struts2.views.velocity.components.URLDirective;
-import org.apache.struts2.views.velocity.components.UpDownSelectDirective;
-
-import com.opensymphony.xwork2.util.ValueStack;
-
/**
* The default Struts tag library
*/
-public class DefaultTagLibrary implements TagLibraryDirectiveProvider, TagLibraryModelProvider {
+public class DefaultTagLibrary implements TagLibraryModelProvider {
public Object getModels(ValueStack stack, HttpServletRequest req,
HttpServletResponse res) {
@@ -74,53 +35,8 @@
return new StrutsModels(stack, req, res);
}
- public List<Class> getDirectiveClasses() {
- Class[] directives = new Class[] {
- ActionDirective.class,
- BeanDirective.class,
- CheckBoxDirective.class,
- CheckBoxListDirective.class,
- ComboBoxDirective.class,
- ComponentDirective.class,
- DateDirective.class,
- DoubleSelectDirective.class,
- FileDirective.class,
- FormDirective.class,
- HeadDirective.class,
- HiddenDirective.class,
- AnchorDirective.class,
- I18nDirective.class,
- IncludeDirective.class,
- LabelDirective.class,
- ParamDirective.class,
- PasswordDirective.class,
- PushDirective.class,
- PropertyDirective.class,
- RadioDirective.class,
- SelectDirective.class,
- SetDirective.class,
- SubmitDirective.class,
- ResetDirective.class,
- TextAreaDirective.class,
- TextDirective.class,
- TextFieldDirective.class,
- TokenDirective.class,
- URLDirective.class,
- ActionErrorDirective.class,
- ActionMessageDirective.class,
- FieldErrorDirective.class,
- OptionTransferSelectDirective.class,
- UpDownSelectDirective.class
- };
- return Arrays.asList(directives);
- }
-
public Object getFreemarkerModels(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
return getModels(stack, req, res);
}
- public List<Class> getVelocityDirectiveClasses() {
- return getDirectiveClasses();
- }
-
}
diff --git a/core/src/main/java/org/apache/struts2/views/TagLibraryDirectiveProvider.java b/core/src/main/java/org/apache/struts2/views/TagLibraryDirectiveProvider.java
index 4df60a0..7636846 100644
--- a/core/src/main/java/org/apache/struts2/views/TagLibraryDirectiveProvider.java
+++ b/core/src/main/java/org/apache/struts2/views/TagLibraryDirectiveProvider.java
@@ -36,6 +36,6 @@
*
* @return A list of Velocity directive classes
*/
- public List<Class> getDirectiveClasses();
+ List<Class> getDirectiveClasses();
}
diff --git a/core/src/main/resources/struts-default.xml b/core/src/main/resources/struts-default.xml
index ed850bd..6ab501d 100644
--- a/core/src/main/resources/struts-default.xml
+++ b/core/src/main/resources/struts-default.xml
@@ -106,16 +106,13 @@
<bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakarta" class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" scope="prototype"/>
<bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakarta-stream" class="org.apache.struts2.dispatcher.multipart.JakartaStreamMultiPartRequest" scope="prototype"/>
- <bean type="org.apache.struts2.views.TagLibraryDirectiveProvider" name="s" class="org.apache.struts2.views.DefaultTagLibrary" />
<bean type="org.apache.struts2.views.TagLibraryModelProvider" name="s" class="org.apache.struts2.views.DefaultTagLibrary" />
<bean class="org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader" />
<bean class="org.apache.struts2.views.freemarker.FreemarkerManager" name="struts" />
- <bean class="org.apache.struts2.views.velocity.VelocityManager" name="struts" optional="true" />
<bean class="org.apache.struts2.components.template.TemplateEngineManager" />
<bean type="org.apache.struts2.components.template.TemplateEngine" name="ftl" class="org.apache.struts2.components.template.FreemarkerTemplateEngine" />
- <bean type="org.apache.struts2.components.template.TemplateEngine" name="vm" class="org.apache.struts2.components.template.VelocityTemplateEngine" />
<bean type="org.apache.struts2.components.template.TemplateEngine" name="jsp" class="org.apache.struts2.components.template.JspTemplateEngine" />
<bean type="com.opensymphony.xwork2.conversion.impl.XWorkConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.XWorkConverter" />
@@ -201,7 +198,6 @@
<result-type name="redirect" class="org.apache.struts2.result.ServletRedirectResult"/>
<result-type name="redirectAction" class="org.apache.struts2.result.ServletActionRedirectResult"/>
<result-type name="stream" class="org.apache.struts2.result.StreamResult"/>
- <result-type name="velocity" class="org.apache.struts2.result.VelocityResult"/>
<result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
<result-type name="plainText" class="org.apache.struts2.result.PlainTextResult" />
<result-type name="postback" class="org.apache.struts2.result.PostbackResult" />
diff --git a/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java b/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java
index 3fb8d0d..dbd406d 100644
--- a/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java
+++ b/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java
@@ -27,8 +27,6 @@
import org.apache.struts2.components.template.Template;
import org.apache.struts2.components.template.TemplateEngine;
import org.apache.struts2.components.template.TemplateEngineManager;
-import org.apache.struts2.components.template.VelocityTemplateEngine;
-import org.apache.struts2.dispatcher.mapper.CompositeActionMapper;
import com.mockobjects.dynamic.C;
import com.mockobjects.dynamic.Mock;
@@ -47,9 +45,8 @@
mgr = new TemplateEngineManager();
mockContainer = new Mock(Container.class);
mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("jsp")), new JspTemplateEngine());
- mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("vm")), new VelocityTemplateEngine());
mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("ftl")), new FreemarkerTemplateEngine());
- mockContainer.matchAndReturn("getInstanceNames", C.args(C.eq(TemplateEngine.class)), new HashSet() {{
+ mockContainer.matchAndReturn("getInstanceNames", C.args(C.eq(TemplateEngine.class)), new HashSet<String>() {{
add("jsp");
add("vm");
add("ftl");
@@ -60,18 +57,13 @@
}
public void testTemplateTypeFromTemplateNameAndDefaults() {
-
TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), null);
assertTrue(engine instanceof JspTemplateEngine);
- engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.vm"), null);
- assertTrue(engine instanceof VelocityTemplateEngine);
}
public void testTemplateTypeOverrides() {
TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), "ftl");
assertTrue(engine instanceof FreemarkerTemplateEngine);
- engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.vm"), "ftl");
- assertTrue(engine instanceof VelocityTemplateEngine);
engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.ftl"), "");
assertTrue(engine instanceof FreemarkerTemplateEngine);
}
@@ -81,7 +73,7 @@
TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), null);
Template template = new Template("/template", "simple", "foo." + TemplateEngineManager.DEFAULT_TEMPLATE_TYPE);
TemplateEngine defaultTemplateEngine = mgr.getTemplateEngine(template, null);
- assertTrue(engine.getClass().equals(defaultTemplateEngine.getClass()));
+ assertEquals(engine.getClass(), defaultTemplateEngine.getClass());
}
protected void tearDown() throws Exception {
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 4ecdd0e..66bb555 100644
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -32,6 +32,7 @@
<name>Struts 2 Plugins</name>
<modules>
+ <module>async</module>
<module>bean-validation</module>
<module>cdi</module>
<module>config-browser</module>
@@ -55,7 +56,7 @@
<module>spring</module>
<module>testng</module>
<module>tiles</module>
- <module>async</module>
+ <module>velocity</module>
</modules>
<dependencies>
diff --git a/plugins/portlet/pom.xml b/plugins/portlet/pom.xml
index 06146d0..81f08b6 100644
--- a/plugins/portlet/pom.xml
+++ b/plugins/portlet/pom.xml
@@ -41,6 +41,11 @@
</dependency>
<dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-velocity-plugin</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<optional>true</optional>
diff --git a/plugins/sitemesh/pom.xml b/plugins/sitemesh/pom.xml
index 66375ae5..8a47ea2 100644
--- a/plugins/sitemesh/pom.xml
+++ b/plugins/sitemesh/pom.xml
@@ -36,16 +36,11 @@
<groupId>opensymphony</groupId>
<artifactId>sitemesh</artifactId>
</dependency>
+
<!-- Velocity -->
<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-tools</artifactId>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-velocity-plugin</artifactId>
<optional>true</optional>
</dependency>
diff --git a/plugins/velocity/pom.xml b/plugins/velocity/pom.xml
new file mode 100644
index 0000000..de58b17
--- /dev/null
+++ b/plugins/velocity/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * 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.
+ */
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-plugins</artifactId>
+ <version>2.6-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>struts2-velocity-plugin</artifactId>
+ <packaging>jar</packaging>
+ <name>Struts 2 Velocity Plugin</name>
+
+ <dependencies>
+
+ <!-- Velocity -->
+ <dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-core</artifactId>
+ </dependency>
+
+ <!-- Velocity -->
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-tools</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ </dependency>
+
+ <!-- The Servlet API mocks in Spring Framework 4.0 support Servlet 3.0 and higher
+ So this is only necessary in tests-->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>mockobjects</groupId>
+ <artifactId>mockobjects-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+</project>
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/StrutsResourceLoader.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java
similarity index 87%
rename from core/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java
index 469e570..f8f6075 100644
--- a/core/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java
+++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java
@@ -24,11 +24,9 @@
public class StrutsVelocityContext extends VelocityContext {
- private static final long serialVersionUID = 8497212428904436963L;
ValueStack stack;
VelocityContext[] chainedContexts;
-
public StrutsVelocityContext(ValueStack stack) {
this(null, stack);
}
@@ -38,7 +36,6 @@
this.stack = stack;
}
-
public boolean internalContainsKey(Object key) {
boolean contains = super.internalContainsKey(key);
@@ -63,8 +60,8 @@
// if we still haven't found it, le's search through our chained contexts
if (chainedContexts != null) {
- for (int index = 0; index < chainedContexts.length; index++) {
- if (chainedContexts[index].containsKey(key)) {
+ for (VelocityContext chainedContext : chainedContexts) {
+ if (chainedContext.containsKey(key)) {
return true;
}
}
@@ -97,9 +94,9 @@
// finally, if we're chained to other contexts, let's look in them
if (chainedContexts != null) {
- for (int index = 0; index < chainedContexts.length; index++) {
- if (chainedContexts[index].containsKey(key)) {
- return chainedContexts[index].internalGet(key);
+ for (VelocityContext chainedContext : chainedContexts) {
+ if (chainedContext.containsKey(key)) {
+ return chainedContext.internalGet(key);
}
}
}
diff --git a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityBeanSelectionProvider.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityBeanSelectionProvider.java
new file mode 100644
index 0000000..5690813
--- /dev/null
+++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityBeanSelectionProvider.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+package org.apache.struts2.views.velocity;
+
+import com.opensymphony.xwork2.config.ConfigurationException;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.util.location.LocatableProperties;
+import org.apache.struts2.config.AbstractBeanSelectionProvider;
+
+/**
+ * Please see {@link org.apache.struts2.config.DefaultBeanSelectionProvider} for more details.
+ *
+ * <p>
+ * The following is a list of the allowed extension points:
+ *
+ * <table border="1" summary="">
+ * <tr>
+ * <th>Type</th>
+ * <th>Property</th>
+ * <th>Scope</th>
+ * <th>Description</th>
+ * </tr>
+ * <tr>
+ * <td>org.apache.struts2.views.velocity.VelocityManager</td>
+ * <td>struts.velocity.manager.classname</td>
+ * <td>singleton</td>
+ * <td>Loads and processes Velocity templates</td>
+ * </tr>
+ * </table>
+ */
+public class VelocityBeanSelectionProvider extends AbstractBeanSelectionProvider {
+
+ @Override
+ public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
+ alias(VelocityManager.class, VelocityConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME, builder, props);
+ }
+
+}
diff --git a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityConstants.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityConstants.java
new file mode 100644
index 0000000..f905662
--- /dev/null
+++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityConstants.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+package org.apache.struts2.views.velocity;
+
+public final class VelocityConstants {
+
+ /** org.apache.struts2.views.velocity.VelocityManager implementation class */
+ public static final String STRUTS_VELOCITY_MANAGER_CLASSNAME = "struts.velocity.manager.classname";
+
+}
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
similarity index 94%
rename from core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
index f94ac7e..b653380 100644
--- a/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
+++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
@@ -53,22 +53,15 @@
* Manages the environment for Velocity result types
*/
public class VelocityManager {
+
private static final Logger LOG = LogManager.getLogger(VelocityManager.class);
+
public static final String STRUTS = "struts";
+
private ObjectFactory objectFactory;
public static final String KEY_VELOCITY_STRUTS_CONTEXT = ".KEY_velocity.struts2.context";
- /**
- * the parent JSP tag
- */
- public static final String PARENT = "parent";
-
- /**
- * the current JSP tag
- */
- public static final String TAG = "tag";
-
private VelocityEngine velocityEngine;
/**
@@ -77,7 +70,6 @@
protected ToolboxManager toolboxManager = null;
private String toolBoxLocation;
-
/**
* Names of contexts that will be chained on every request
*/
@@ -137,8 +129,8 @@
VelocityContext[] chainedContexts = prepareChainedContexts(req, res, stack.getContext());
StrutsVelocityContext context = new StrutsVelocityContext(chainedContexts, stack);
Map standardMap = ContextUtil.getStandardContext(stack, req, res);
- for (Iterator iterator = standardMap.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry entry = (Map.Entry) iterator.next();
+ for (Object o : standardMap.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
context.put((String) entry.getKey(), entry.getValue());
}
context.put(STRUTS, new VelocityStrutsUtil(velocityEngine, context, stack, req, res));
@@ -236,13 +228,13 @@
String defaultUserDirective = properties.getProperty("userdirective");
- /**
- * if the user has specified an external velocity configuration file, we'll want to search for it in the
- * following order
- *
- * 1. relative to the context path
- * 2. relative to /WEB-INF
- * 3. in the class path
+ /*
+ if the user has specified an external velocity configuration file, we'll want to search for it in the
+ following order
+
+ 1. relative to the context path
+ 2. relative to /WEB-INF
+ 3. in the class path
*/
String configfile;
@@ -301,16 +293,15 @@
if (in != null) {
try {
in.close();
- } catch (IOException e) {
+ } catch (IOException ignore) {
}
}
}
// overide with programmatically set properties
if (this.velocityProperties != null) {
- Iterator keys = this.velocityProperties.keySet().iterator();
- while (keys.hasNext()) {
- String key = (String) keys.next();
+ for (Object o : this.velocityProperties.keySet()) {
+ String key = (String) o;
properties.setProperty(key, this.velocityProperties.getProperty(key));
}
}
@@ -330,8 +321,8 @@
if (LOG.isDebugEnabled()) {
LOG.debug("Initializing Velocity with the following properties ...");
- for (Iterator iter = properties.keySet().iterator(); iter.hasNext(); ) {
- String key = (String) iter.next();
+ for (Object o : properties.keySet()) {
+ String key = (String) o;
String value = properties.getProperty(key);
LOG.debug(" '{}' = '{}'", key, value);
}
@@ -394,9 +385,6 @@
}
}
-
-
-
/**
* <p>
* Instantiates a new VelocityEngine.
@@ -488,11 +476,11 @@
} else {
// remove strutsfile from resource loader property
String prop = properties.getProperty(Velocity.RESOURCE_LOADER);
- if (prop.indexOf("strutsfile,") != -1) {
+ if (prop.contains("strutsfile,")) {
prop = replace(prop, "strutsfile,", "");
- } else if (prop.indexOf(", strutsfile") != -1) {
+ } else if (prop.contains(", strutsfile")) {
prop = replace(prop, ", strutsfile", "");
- } else if (prop.indexOf("strutsfile") != -1) {
+ } else if (prop.contains("strutsfile")) {
prop = replace(prop, "strutsfile", "");
}
@@ -536,7 +524,7 @@
sb.append(clazz.getName()).append(",");
}
- private static final String replace(String string, String oldString, String newString) {
+ private String replace(String string, String oldString, String newString) {
if (string == null) {
return null;
}
diff --git a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityTagLibrary.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityTagLibrary.java
new file mode 100644
index 0000000..6135164
--- /dev/null
+++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityTagLibrary.java
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+package org.apache.struts2.views.velocity;
+
+import org.apache.struts2.views.TagLibraryDirectiveProvider;
+import org.apache.struts2.views.velocity.components.ActionDirective;
+import org.apache.struts2.views.velocity.components.ActionErrorDirective;
+import org.apache.struts2.views.velocity.components.ActionMessageDirective;
+import org.apache.struts2.views.velocity.components.AnchorDirective;
+import org.apache.struts2.views.velocity.components.BeanDirective;
+import org.apache.struts2.views.velocity.components.CheckBoxDirective;
+import org.apache.struts2.views.velocity.components.CheckBoxListDirective;
+import org.apache.struts2.views.velocity.components.ComboBoxDirective;
+import org.apache.struts2.views.velocity.components.ComponentDirective;
+import org.apache.struts2.views.velocity.components.DateDirective;
+import org.apache.struts2.views.velocity.components.DoubleSelectDirective;
+import org.apache.struts2.views.velocity.components.FieldErrorDirective;
+import org.apache.struts2.views.velocity.components.FileDirective;
+import org.apache.struts2.views.velocity.components.FormDirective;
+import org.apache.struts2.views.velocity.components.HeadDirective;
+import org.apache.struts2.views.velocity.components.HiddenDirective;
+import org.apache.struts2.views.velocity.components.I18nDirective;
+import org.apache.struts2.views.velocity.components.IncludeDirective;
+import org.apache.struts2.views.velocity.components.LabelDirective;
+import org.apache.struts2.views.velocity.components.OptionTransferSelectDirective;
+import org.apache.struts2.views.velocity.components.ParamDirective;
+import org.apache.struts2.views.velocity.components.PasswordDirective;
+import org.apache.struts2.views.velocity.components.PropertyDirective;
+import org.apache.struts2.views.velocity.components.PushDirective;
+import org.apache.struts2.views.velocity.components.RadioDirective;
+import org.apache.struts2.views.velocity.components.ResetDirective;
+import org.apache.struts2.views.velocity.components.SelectDirective;
+import org.apache.struts2.views.velocity.components.SetDirective;
+import org.apache.struts2.views.velocity.components.SubmitDirective;
+import org.apache.struts2.views.velocity.components.TextAreaDirective;
+import org.apache.struts2.views.velocity.components.TextDirective;
+import org.apache.struts2.views.velocity.components.TextFieldDirective;
+import org.apache.struts2.views.velocity.components.TokenDirective;
+import org.apache.struts2.views.velocity.components.URLDirective;
+import org.apache.struts2.views.velocity.components.UpDownSelectDirective;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class VelocityTagLibrary implements TagLibraryDirectiveProvider {
+
+ @Override
+ public List<Class> getDirectiveClasses() {
+ Class[] directives = new Class[] {
+ ActionDirective.class,
+ BeanDirective.class,
+ CheckBoxDirective.class,
+ CheckBoxListDirective.class,
+ ComboBoxDirective.class,
+ ComponentDirective.class,
+ DateDirective.class,
+ DoubleSelectDirective.class,
+ FileDirective.class,
+ FormDirective.class,
+ HeadDirective.class,
+ HiddenDirective.class,
+ AnchorDirective.class,
+ I18nDirective.class,
+ IncludeDirective.class,
+ LabelDirective.class,
+ ParamDirective.class,
+ PasswordDirective.class,
+ PushDirective.class,
+ PropertyDirective.class,
+ RadioDirective.class,
+ SelectDirective.class,
+ SetDirective.class,
+ SubmitDirective.class,
+ ResetDirective.class,
+ TextAreaDirective.class,
+ TextDirective.class,
+ TextFieldDirective.class,
+ TokenDirective.class,
+ URLDirective.class,
+ ActionErrorDirective.class,
+ ActionMessageDirective.class,
+ FieldErrorDirective.class,
+ OptionTransferSelectDirective.class,
+ UpDownSelectDirective.class
+ };
+ return Arrays.asList(directives);
+ }
+
+ /**
+ * @deprecated please use {#getDirectiveClasses}
+ */
+ @Deprecated()
+ public List<Class> getVelocityDirectiveClasses() {
+ return getDirectiveClasses();
+ }
+
+}
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/ActionDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ActionDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/ActionDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ActionDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/ActionErrorDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ActionErrorDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/ActionErrorDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ActionErrorDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/ActionMessageDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ActionMessageDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/ActionMessageDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ActionMessageDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/AnchorDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/AnchorDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/AnchorDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/AnchorDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/BeanDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/BeanDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/BeanDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/BeanDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/CheckBoxDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/CheckBoxDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/CheckBoxDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/CheckBoxDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/CheckBoxListDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/CheckBoxListDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/CheckBoxListDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/CheckBoxListDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/ComboBoxDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ComboBoxDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/ComboBoxDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ComboBoxDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/ComponentDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ComponentDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/ComponentDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ComponentDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/DateDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/DateDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/DateDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/DateDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/DoubleSelectDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/DoubleSelectDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/DoubleSelectDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/DoubleSelectDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/FieldErrorDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/FieldErrorDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/FieldErrorDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/FieldErrorDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/FileDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/FileDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/FileDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/FileDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/FormDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/FormDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/FormDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/FormDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/HeadDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/HeadDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/HeadDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/HeadDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/HiddenDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/HiddenDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/HiddenDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/HiddenDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/I18nDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/I18nDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/I18nDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/I18nDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/IncludeDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/IncludeDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/IncludeDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/IncludeDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/InputTransferSelectDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/InputTransferSelectDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/InputTransferSelectDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/InputTransferSelectDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/LabelDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/LabelDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/LabelDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/LabelDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/OptGroupDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/OptGroupDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/OptGroupDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/OptGroupDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/OptionTransferSelectDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/OptionTransferSelectDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/OptionTransferSelectDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/OptionTransferSelectDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/ParamDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ParamDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/ParamDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ParamDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/PasswordDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/PasswordDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/PasswordDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/PasswordDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/PropertyDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/PropertyDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/PropertyDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/PropertyDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/PushDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/PushDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/PushDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/PushDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/RadioDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/RadioDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/RadioDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/RadioDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/ResetDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ResetDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/ResetDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/ResetDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/SelectDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/SelectDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/SelectDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/SelectDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/SetDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/SetDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/SetDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/SetDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/SubmitDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/SubmitDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/SubmitDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/SubmitDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/TextAreaDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/TextAreaDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/TextAreaDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/TextAreaDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/TextDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/TextDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/TextDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/TextDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/TextFieldDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/TextFieldDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/TextFieldDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/TextFieldDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/TokenDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/TokenDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/TokenDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/TokenDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/URLDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/URLDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/URLDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/URLDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/components/UpDownSelectDirective.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/UpDownSelectDirective.java
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/components/UpDownSelectDirective.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/components/UpDownSelectDirective.java
diff --git a/core/src/main/java/org/apache/struts2/views/velocity/package.html b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/package.html
similarity index 100%
rename from core/src/main/java/org/apache/struts2/views/velocity/package.html
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/package.html
diff --git a/core/src/main/java/org/apache/struts2/result/VelocityResult.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/result/VelocityResult.java
similarity index 98%
rename from core/src/main/java/org/apache/struts2/result/VelocityResult.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/result/VelocityResult.java
index b552fb7..c62f687 100644
--- a/core/src/main/java/org/apache/struts2/result/VelocityResult.java
+++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/result/VelocityResult.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.struts2.result;
+package org.apache.struts2.views.velocity.result;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
@@ -26,6 +26,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.result.StrutsResultSupport;
import org.apache.struts2.views.JspSupportServlet;
import org.apache.struts2.views.velocity.VelocityManager;
import org.apache.velocity.Template;
diff --git a/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/template/VelocityTemplateEngine.java
similarity index 93%
rename from core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java
rename to plugins/velocity/src/main/java/org/apache/struts2/views/velocity/template/VelocityTemplateEngine.java
index 24f4564..423029e 100644
--- a/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java
+++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/template/VelocityTemplateEngine.java
@@ -16,12 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.struts2.components.template;
+package org.apache.struts2.views.velocity.template;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.components.template.BaseTemplateEngine;
+import org.apache.struts2.components.template.Template;
+import org.apache.struts2.components.template.TemplateRenderingContext;
import org.apache.struts2.views.velocity.VelocityManager;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.context.Context;
@@ -29,7 +32,6 @@
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
import java.io.Writer;
import java.util.List;
import java.util.Map;
diff --git a/plugins/velocity/src/main/resources/struts-plugin.xml b/plugins/velocity/src/main/resources/struts-plugin.xml
new file mode 100644
index 0000000..00a4207
--- /dev/null
+++ b/plugins/velocity/src/main/resources/struts-plugin.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+/*
+ * 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.
+ */
+-->
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
+ "http://struts.apache.org/dtds/struts-2.5.dtd">
+
+<struts>
+ <bean class="org.apache.struts2.views.velocity.VelocityManager" name="struts" />
+
+ <bean type="org.apache.struts2.components.template.TemplateEngine" name="vm"
+ class="org.apache.struts2.views.velocity.template.VelocityTemplateEngine" />
+
+ <bean type="org.apache.struts2.views.TagLibraryDirectiveProvider" name="s"
+ class="org.apache.struts2.views.velocity.VelocityTagLibrary" />
+
+ <package name="velocity-default" extends="struts-default">
+ <result-types>
+ <result-type name="velocity" class="org.apache.struts2.views.velocity.result.VelocityResult"/>
+ </result-types>
+ </package>
+
+</struts>
diff --git a/core/src/main/resources/template/archive/ajax/a-close.vm b/plugins/velocity/src/main/resources/template/velocity/ajax/a-close.vm
similarity index 100%
rename from core/src/main/resources/template/archive/ajax/a-close.vm
rename to plugins/velocity/src/main/resources/template/velocity/ajax/a-close.vm
diff --git a/core/src/main/resources/template/archive/ajax/a.vm b/plugins/velocity/src/main/resources/template/velocity/ajax/a.vm
similarity index 100%
rename from core/src/main/resources/template/archive/ajax/a.vm
rename to plugins/velocity/src/main/resources/template/velocity/ajax/a.vm
diff --git a/core/src/main/resources/template/archive/ajax/div-close.vm b/plugins/velocity/src/main/resources/template/velocity/ajax/div-close.vm
similarity index 100%
rename from core/src/main/resources/template/archive/ajax/div-close.vm
rename to plugins/velocity/src/main/resources/template/velocity/ajax/div-close.vm
diff --git a/core/src/main/resources/template/archive/ajax/div.vm b/plugins/velocity/src/main/resources/template/velocity/ajax/div.vm
similarity index 100%
rename from core/src/main/resources/template/archive/ajax/div.vm
rename to plugins/velocity/src/main/resources/template/velocity/ajax/div.vm
diff --git a/core/src/main/resources/template/archive/ajax/form-close.vm b/plugins/velocity/src/main/resources/template/velocity/ajax/form-close.vm
similarity index 100%
rename from core/src/main/resources/template/archive/ajax/form-close.vm
rename to plugins/velocity/src/main/resources/template/velocity/ajax/form-close.vm
diff --git a/core/src/main/resources/template/archive/ajax/form.vm b/plugins/velocity/src/main/resources/template/velocity/ajax/form.vm
similarity index 100%
rename from core/src/main/resources/template/archive/ajax/form.vm
rename to plugins/velocity/src/main/resources/template/velocity/ajax/form.vm
diff --git a/core/src/main/resources/template/archive/ajax/submit.vm b/plugins/velocity/src/main/resources/template/velocity/ajax/submit.vm
similarity index 100%
rename from core/src/main/resources/template/archive/ajax/submit.vm
rename to plugins/velocity/src/main/resources/template/velocity/ajax/submit.vm
diff --git a/core/src/main/resources/template/archive/ajax/tab-close.vm b/plugins/velocity/src/main/resources/template/velocity/ajax/tab-close.vm
similarity index 100%
rename from core/src/main/resources/template/archive/ajax/tab-close.vm
rename to plugins/velocity/src/main/resources/template/velocity/ajax/tab-close.vm
diff --git a/core/src/main/resources/template/archive/ajax/tab.vm b/plugins/velocity/src/main/resources/template/velocity/ajax/tab.vm
similarity index 100%
rename from core/src/main/resources/template/archive/ajax/tab.vm
rename to plugins/velocity/src/main/resources/template/velocity/ajax/tab.vm
diff --git a/core/src/main/resources/template/archive/simple/checkbox.vm b/plugins/velocity/src/main/resources/template/velocity/simple/checkbox.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/checkbox.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/checkbox.vm
diff --git a/core/src/main/resources/template/archive/simple/checkboxlist.vm b/plugins/velocity/src/main/resources/template/velocity/simple/checkboxlist.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/checkboxlist.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/checkboxlist.vm
diff --git a/core/src/main/resources/template/archive/simple/combobox.vm b/plugins/velocity/src/main/resources/template/velocity/simple/combobox.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/combobox.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/combobox.vm
diff --git a/core/src/main/resources/template/archive/simple/debug.vm b/plugins/velocity/src/main/resources/template/velocity/simple/debug.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/debug.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/debug.vm
diff --git a/core/src/main/resources/template/archive/simple/doubleselect.vm b/plugins/velocity/src/main/resources/template/velocity/simple/doubleselect.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/doubleselect.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/doubleselect.vm
diff --git a/core/src/main/resources/template/archive/simple/empty.vm b/plugins/velocity/src/main/resources/template/velocity/simple/empty.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/empty.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/empty.vm
diff --git a/core/src/main/resources/template/archive/simple/file.vm b/plugins/velocity/src/main/resources/template/velocity/simple/file.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/file.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/file.vm
diff --git a/core/src/main/resources/template/archive/simple/form-close.vm b/plugins/velocity/src/main/resources/template/velocity/simple/form-close.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/form-close.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/form-close.vm
diff --git a/core/src/main/resources/template/archive/simple/form.vm b/plugins/velocity/src/main/resources/template/velocity/simple/form.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/form.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/form.vm
diff --git a/core/src/main/resources/template/archive/simple/hidden.vm b/plugins/velocity/src/main/resources/template/velocity/simple/hidden.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/hidden.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/hidden.vm
diff --git a/core/src/main/resources/template/archive/simple/label.vm b/plugins/velocity/src/main/resources/template/velocity/simple/label.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/label.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/label.vm
diff --git a/core/src/main/resources/template/archive/simple/password.vm b/plugins/velocity/src/main/resources/template/velocity/simple/password.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/password.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/password.vm
diff --git a/core/src/main/resources/template/archive/simple/radiomap.vm b/plugins/velocity/src/main/resources/template/velocity/simple/radiomap.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/radiomap.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/radiomap.vm
diff --git a/core/src/main/resources/template/archive/simple/scripting-events.vm b/plugins/velocity/src/main/resources/template/velocity/simple/scripting-events.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/scripting-events.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/scripting-events.vm
diff --git a/core/src/main/resources/template/archive/simple/select.vm b/plugins/velocity/src/main/resources/template/velocity/simple/select.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/select.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/select.vm
diff --git a/core/src/main/resources/template/archive/simple/submit.vm b/plugins/velocity/src/main/resources/template/velocity/simple/submit.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/submit.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/submit.vm
diff --git a/core/src/main/resources/template/archive/simple/table.vm b/plugins/velocity/src/main/resources/template/velocity/simple/table.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/table.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/table.vm
diff --git a/core/src/main/resources/template/archive/simple/text.vm b/plugins/velocity/src/main/resources/template/velocity/simple/text.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/text.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/text.vm
diff --git a/core/src/main/resources/template/archive/simple/textarea.vm b/plugins/velocity/src/main/resources/template/velocity/simple/textarea.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/textarea.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/textarea.vm
diff --git a/core/src/main/resources/template/archive/simple/token.vm b/plugins/velocity/src/main/resources/template/velocity/simple/token.vm
similarity index 100%
rename from core/src/main/resources/template/archive/simple/token.vm
rename to plugins/velocity/src/main/resources/template/velocity/simple/token.vm
diff --git a/core/src/main/resources/template/archive/xhtml/checkbox.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/checkbox.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/checkbox.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/checkbox.vm
diff --git a/core/src/main/resources/template/archive/xhtml/checkboxlist.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/checkboxlist.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/checkboxlist.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/checkboxlist.vm
diff --git a/core/src/main/resources/template/archive/xhtml/combobox.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/combobox.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/combobox.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/combobox.vm
diff --git a/core/src/main/resources/template/archive/xhtml/controlfooter.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/controlfooter.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/controlfooter.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/controlfooter.vm
diff --git a/core/src/main/resources/template/archive/xhtml/controlheader.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/controlheader.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/controlheader.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/controlheader.vm
diff --git a/core/src/main/resources/template/archive/xhtml/debug.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/debug.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/debug.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/debug.vm
diff --git a/core/src/main/resources/template/archive/xhtml/doubleselect.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/doubleselect.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/doubleselect.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/doubleselect.vm
diff --git a/core/src/main/resources/template/archive/xhtml/empty.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/empty.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/empty.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/empty.vm
diff --git a/core/src/main/resources/template/archive/xhtml/file.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/file.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/file.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/file.vm
diff --git a/core/src/main/resources/template/archive/xhtml/form-close.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/form-close.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/form-close.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/form-close.vm
diff --git a/core/src/main/resources/template/archive/xhtml/form.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/form.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/form.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/form.vm
diff --git a/core/src/main/resources/template/archive/xhtml/hidden.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/hidden.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/hidden.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/hidden.vm
diff --git a/core/src/main/resources/template/archive/xhtml/label.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/label.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/label.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/label.vm
diff --git a/core/src/main/resources/template/archive/xhtml/password.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/password.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/password.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/password.vm
diff --git a/core/src/main/resources/template/archive/xhtml/radiomap.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/radiomap.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/radiomap.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/radiomap.vm
diff --git a/core/src/main/resources/template/archive/xhtml/select.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/select.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/select.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/select.vm
diff --git a/core/src/main/resources/template/archive/xhtml/submit.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/submit.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/submit.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/submit.vm
diff --git a/core/src/main/resources/template/archive/xhtml/table.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/table.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/table.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/table.vm
diff --git a/core/src/main/resources/template/archive/xhtml/text.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/text.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/text.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/text.vm
diff --git a/core/src/main/resources/template/archive/xhtml/textarea.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/textarea.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/textarea.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/textarea.vm
diff --git a/core/src/main/resources/template/archive/xhtml/token.vm b/plugins/velocity/src/main/resources/template/velocity/xhtml/token.vm
similarity index 100%
rename from core/src/main/resources/template/archive/xhtml/token.vm
rename to plugins/velocity/src/main/resources/template/velocity/xhtml/token.vm
diff --git a/core/src/test/java/org/apache/struts2/result/VelocityResultTest.java b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/result/VelocityResultTest.java
similarity index 85%
rename from core/src/test/java/org/apache/struts2/result/VelocityResultTest.java
rename to plugins/velocity/src/test/java/org/apache/struts2/views/velocity/result/VelocityResultTest.java
index 9ba000f..7fa4bb9 100644
--- a/core/src/test/java/org/apache/struts2/result/VelocityResultTest.java
+++ b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/result/VelocityResultTest.java
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.struts2.result;
+package org.apache.struts2.views.velocity.result;
-import org.apache.struts2.StrutsInternalTestCase;
+import com.opensymphony.xwork2.XWorkTestCase;
+import junit.framework.TestCase;
import org.apache.struts2.result.StrutsResultSupport;
-import org.apache.struts2.result.VelocityResult;
import org.apache.velocity.Template;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.ParseErrorException;
@@ -36,7 +36,7 @@
/**
*
*/
-public class VelocityResultTest extends StrutsInternalTestCase {
+public class VelocityResultTest extends XWorkTestCase {
ActionInvocation actionInvocation;
Mock mockActionProxy;
@@ -56,11 +56,11 @@
ValueStack stack = ActionContext.getContext().getValueStack();
stack.push(bean);
- assertEquals(location, stack.findValue("location"));
+ TestCase.assertEquals(location, stack.findValue("location"));
result.setLocation("${location}");
result.execute(actionInvocation);
- assertEquals(location, result.finalLocation);
+ TestCase.assertEquals(location, result.finalLocation);
}
public void testCanResolveLocationUsingStaticExpression() throws Exception {
@@ -68,15 +68,15 @@
String location = "/any.action";
result.setLocation("${'" + location + "'}");
result.execute(actionInvocation);
- assertEquals(location, result.finalLocation);
+ TestCase.assertEquals(location, result.finalLocation);
}
public void testResourcesFoundUsingAbsolutePath() throws Exception {
String location = "/WEB-INF/views/registration.vm";
Template template = result.getTemplate(stack, velocity, actionInvocation, location, "UTF-8");
- assertNotNull(template);
- assertEquals("expect absolute locations to be handled as is", location, velocity.templateName);
+ TestCase.assertNotNull(template);
+ TestCase.assertEquals("expect absolute locations to be handled as is", location, velocity.templateName);
}
public void testResourcesFoundUsingNames() throws Exception {
@@ -84,8 +84,8 @@
String expectedTemplateName = namespace + "/" + location;
Template template = result.getTemplate(stack, velocity, actionInvocation, location, "UTF-8");
- assertNotNull(template);
- assertEquals("expect the prefix to be appended to the path when the location is not absolute", expectedTemplateName, velocity.templateName);
+ TestCase.assertNotNull(template);
+ TestCase.assertEquals("expect the prefix to be appended to the path when the location is not absolute", expectedTemplateName, velocity.templateName);
}
protected void setUp() throws Exception {
diff --git a/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/template/VelocityTemplateEngineTest.java b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/template/VelocityTemplateEngineTest.java
new file mode 100644
index 0000000..b206e2a
--- /dev/null
+++ b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/template/VelocityTemplateEngineTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+package org.apache.struts2.views.velocity.template;
+
+import com.mockobjects.dynamic.C;
+import com.mockobjects.dynamic.Mock;
+import com.opensymphony.xwork2.XWorkTestCase;
+import com.opensymphony.xwork2.inject.Container;
+import org.apache.struts2.components.template.FreemarkerTemplateEngine;
+import org.apache.struts2.components.template.JspTemplateEngine;
+import org.apache.struts2.components.template.Template;
+import org.apache.struts2.components.template.TemplateEngine;
+import org.apache.struts2.components.template.TemplateEngineManager;
+
+import java.util.HashSet;
+
+public class VelocityTemplateEngineTest extends XWorkTestCase {
+
+ private TemplateEngineManager mgr;
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ mgr = new TemplateEngineManager();
+ Mock mockContainer = new Mock(Container.class);
+ mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("jsp")), new JspTemplateEngine());
+ mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("vm")), new VelocityTemplateEngine());
+ mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("ftl")), new FreemarkerTemplateEngine());
+ mockContainer.matchAndReturn("getInstanceNames", C.args(C.eq(TemplateEngine.class)), new HashSet<String>() {{
+ add("jsp");
+ add("vm");
+ add("ftl");
+ }});
+
+ mgr.setContainer((Container) mockContainer.proxy());
+ mgr.setDefaultTemplateType("jsp");
+ }
+
+ public void testTemplateTypeFromTemplateNameAndDefaults() {
+
+ TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), null);
+ assertTrue(engine instanceof JspTemplateEngine);
+ engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.vm"), null);
+ assertTrue(engine instanceof VelocityTemplateEngine);
+ }
+
+ public void testTemplateTypeOverrides() {
+ TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), "ftl");
+ assertTrue(engine instanceof FreemarkerTemplateEngine);
+ engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.vm"), "ftl");
+ assertTrue(engine instanceof VelocityTemplateEngine);
+ engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.ftl"), "");
+ assertTrue(engine instanceof FreemarkerTemplateEngine);
+ }
+
+ public void testTemplateTypeUsesDefaultWhenNotSetInConfiguration() {
+ mgr.setDefaultTemplateType(null);
+ TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), null);
+ Template template = new Template("/template", "simple", "foo." + TemplateEngineManager.DEFAULT_TEMPLATE_TYPE);
+ TemplateEngine defaultTemplateEngine = mgr.getTemplateEngine(template, null);
+ assertEquals(engine.getClass(), defaultTemplateEngine.getClass());
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index f8128dc..c8c6387 100644
--- a/pom.xml
+++ b/pom.xml
@@ -691,6 +691,11 @@
<artifactId>struts2-osgi-demo-bundle</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-velocity-plugin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.freemarker</groupId>
@@ -731,7 +736,6 @@
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
- <optional>true</optional>
</dependency>
<dependency>