struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [struts] 01/02: WW-5047 Sets proper order of configuration elements
Date Wed, 27 Nov 2019 18:59:51 GMT
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch WW-5047-new-velocity
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 02b428b6e5687c6a4bfef88f80e86a116883dc19
Author: Lukasz Lenart <lukaszlenart@apache.org>
AuthorDate: Wed Nov 27 19:58:46 2019 +0100

    WW-5047 Sets proper order of configuration elements
---
 .../xwork2/config/providers/XmlConfigurationProvider.java  |  7 ++++---
 core/src/main/resources/struts-2.6.dtd                     | 14 +++++++-------
 core/src/main/resources/xwork-2.6.dtd                      | 14 +++++++-------
 plugins/velocity/src/main/resources/struts-plugin.xml      |  6 +++---
 4 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java
b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java
index 40e5cac..9b2a7ad 100644
--- a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java
+++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java
@@ -23,6 +23,7 @@ import com.opensymphony.xwork2.FileManager;
 import com.opensymphony.xwork2.FileManagerFactory;
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.XWorkException;
+import com.opensymphony.xwork2.config.BeanSelectionProvider;
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
@@ -225,11 +226,11 @@ public class XmlConfigurationProvider implements ConfigurationProvider
{
                         String impl = child.getAttribute("class");
                         try {
                             Class classImpl = ClassLoaderUtil.loadClass(impl, getClass());
-                            if (ConfigurationProvider.class.isAssignableFrom(classImpl))
{
-                                ConfigurationProvider provider = (ConfigurationProvider)
classImpl.newInstance();
+                            if (BeanSelectionProvider.class.isAssignableFrom(classImpl))
{
+                                BeanSelectionProvider provider = (BeanSelectionProvider)
classImpl.newInstance();
                                 provider.register(containerBuilder, props);
                             } else {
-                                throw new ConfigurationException("The bean-provider: name:"
+ name + " class:" + impl + " doesnt implement " + ConfigurationProvider.class.getName(),
childNode);
+                                throw new ConfigurationException("The bean-provider: name:"
+ name + " class:" + impl + " does not implement " + BeanSelectionProvider.class.getName(),
childNode);
                             }
                         } catch (ClassNotFoundException | IllegalAccessException | InstantiationException
e) {
                             throw new ConfigurationException("Unable to load bean-provider:
name:" + name + " class:" + impl, e, childNode);
diff --git a/core/src/main/resources/struts-2.6.dtd b/core/src/main/resources/struts-2.6.dtd
index 6eb5654..84714cc 100644
--- a/core/src/main/resources/struts-2.6.dtd
+++ b/core/src/main/resources/struts-2.6.dtd
@@ -30,7 +30,7 @@
 	"http://struts.apache.org/dtds/struts-2.6.dtd">
 -->
 
-<!ELEMENT struts ((package|include|bean-provider|bean|constant)*, unknown-handler-stack?)>
+<!ELEMENT struts ((package|include|bean|constant)*,bean-provider?, unknown-handler-stack?)>
 <!ATTLIST struts
     order CDATA #IMPLIED
 >
@@ -125,12 +125,6 @@
     file CDATA #REQUIRED
 >
 
-<!ELEMENT bean-provider (#PCDATA)>
-<!ATTLIST bean-provider
-    name CDATA #IMPLIED
-    class CDATA #IMPLIED
->
-
 <!ELEMENT bean (#PCDATA)>
 <!ATTLIST bean
     type CDATA #IMPLIED
@@ -141,6 +135,12 @@
     optional CDATA #IMPLIED
 >
 
+<!ELEMENT bean-provider (#PCDATA)>
+<!ATTLIST bean-provider
+    name CDATA #IMPLIED
+    class CDATA #IMPLIED
+>
+
 <!ELEMENT constant (#PCDATA)>
 <!ATTLIST constant
     name CDATA #REQUIRED
diff --git a/core/src/main/resources/xwork-2.6.dtd b/core/src/main/resources/xwork-2.6.dtd
index 6f0e319..8c70840 100644
--- a/core/src/main/resources/xwork-2.6.dtd
+++ b/core/src/main/resources/xwork-2.6.dtd
@@ -30,7 +30,7 @@
 	"http://struts.apache.org/dtds/xwork-2.6.dtd">
 -->
 
-<!ELEMENT xwork ((package|include|bean-provider|bean|constant)*, unknown-handler-stack?)>
+<!ELEMENT xwork ((package|include|bean|constant)*, bean-provider?, unknown-handler-stack?)>
 <!ATTLIST xwork
     order CDATA #IMPLIED
 >
@@ -125,12 +125,6 @@
     file CDATA #REQUIRED
 >
 
-<!ELEMENT bean-provider (#PCDATA)>
-<!ATTLIST bean-provider
-    name CDATA #IMPLIED
-    class CDATA #IMPLIED
->
-
 <!ELEMENT bean (#PCDATA)>
 <!ATTLIST bean
     type CDATA #IMPLIED
@@ -141,6 +135,12 @@
     optional CDATA #IMPLIED
 >
 
+<!ELEMENT bean-provider (#PCDATA)>
+<!ATTLIST bean-provider
+    name CDATA #IMPLIED
+    class CDATA #IMPLIED
+>
+
 <!ELEMENT constant (#PCDATA)>
 <!ATTLIST constant
     name CDATA #REQUIRED
diff --git a/plugins/velocity/src/main/resources/struts-plugin.xml b/plugins/velocity/src/main/resources/struts-plugin.xml
index 435fab9..b4fabf5 100644
--- a/plugins/velocity/src/main/resources/struts-plugin.xml
+++ b/plugins/velocity/src/main/resources/struts-plugin.xml
@@ -25,9 +25,7 @@
     
 <struts>
 
-    <bean-provider name="velocityBeans" class="org.apache.struts2.views.velocity.VelocityBeanSelectionProvider"/>
-
-    <bean class="org.apache.struts2.views.velocity.VelocityManager" />
+    <bean name="struts" class="org.apache.struts2.views.velocity.VelocityManager" />
 
     <bean type="org.apache.struts2.components.template.TemplateEngine" name="vm"
           class="org.apache.struts2.views.velocity.template.VelocityTemplateEngine" />
@@ -41,4 +39,6 @@
         </result-types>
     </package>
 
+    <bean-provider name="velocityBeans" class="org.apache.struts2.views.velocity.VelocityBeanSelectionProvider"/>
+
 </struts>


Mime
View raw message