WW-3123 Add constant to Convention to prevent mapping default action to execute if other mappings exist on the same class

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@773894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Musachy Barroso
2009-05-12 13:44:17 +00:00
parent ef0eca1083
commit 4a56baf819
2 changed files with 13 additions and 1 deletions
@@ -99,6 +99,7 @@ public class PackageBasedActionConfigBuilder implements ActionConfigBuilder {
private ReloadingClassLoader reloadingClassLoader;
private boolean reload;
private Set<String> fileProtocols;
private boolean alwaysMapExecute;
private static final String DEFAULT_METHOD = "execute";
@@ -145,6 +146,15 @@ public class PackageBasedActionConfigBuilder implements ActionConfigBuilder {
this.reload = "true".equals(reload);
}
/**
* 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 @@ public class PackageBasedActionConfigBuilder implements ActionConfigBuilder {
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);
@@ -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" />