You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2009/05/12 15:44:17 UTC

svn commit: r773894 - in /struts/struts2/trunk/plugins/convention/src/main: java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java resources/struts-plugin.xml

Author: musachy
Date: Tue May 12 13:44:17 2009
New Revision: 773894

URL: http://svn.apache.org/viewvc?rev=773894&view=rev
Log:
WW-3123 Add constant to Convention to prevent mapping default action to execute if other mappings exist on the same class

Modified:
    struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
    struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml

Modified: struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java?rev=773894&r1=773893&r2=773894&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java (original)
+++ struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java Tue May 12 13:44:17 2009
@@ -99,6 +99,7 @@
     private ReloadingClassLoader reloadingClassLoader;
     private boolean reload;
     private Set<String> fileProtocols;
+    private boolean alwaysMapExecute;
 
     private static final String DEFAULT_METHOD = "execute";
 
@@ -146,6 +147,15 @@
     }
 
     /**
+     * If this constant is true, and there is an "execute" method(not annotated), a mapping will be added
+     * pointing to it, even if there are other mapping in the class
+     */
+    @Inject("struts.convention.action.alwaysMapExecute")
+    public void setAlwaysMapExecute(String alwaysMapExecute) {
+        this.alwaysMapExecute = "true".equals(alwaysMapExecute);
+    }
+
+    /**
      * File URLs whose protocol are in these list will be processed as jars containing classes 
      * @param fileProtocols Comma separated list of file protocols that will be considered as jar files and scanned
      */
@@ -513,7 +523,8 @@
                 boolean hasDefaultMethod = ReflectionTools.containsMethod(actionClass, DEFAULT_METHOD);
                 if (!map.containsKey(DEFAULT_METHOD)
                         && hasDefaultMethod
-                        && actionAnnotation == null && actionsAnnotation == null) {
+                        && actionAnnotation == null && actionsAnnotation == null
+                        && (alwaysMapExecute || map.isEmpty())) {
                     boolean found = false;
                     for (String method : map.keySet()) {
                         List<Action> actions = map.get(method);

Modified: struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml?rev=773894&r1=773893&r2=773894&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml (original)
+++ struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml Tue May 12 13:44:17 2009
@@ -59,6 +59,7 @@
   <constant name="struts.convention.exclude.packages" value="org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*"/>
   <constant name="struts.convention.relative.result.types" value="dispatcher,velocity,freemarker"/>
   <constant name="struts.convention.redirect.to.slash" value="true"/>
+  <constant name="struts.convention.action.alwaysMapExecute" value="true"/>
   <constant name="struts.mapper.alwaysSelectFullNamespace" value="true"/>
   <!-- <constant name="struts.convention.action.includeJars"  /> -->
   <constant name="struts.convention.action.fileProtocols" value="jar" />