From 030c7e01936906b554a621555d80519769874547 Mon Sep 17 00:00:00 2001 From: Musachy Barroso Date: Tue, 16 Dec 2008 17:47:24 +0000 Subject: [PATCH] XW-640 Support multiple unknown handlers git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@727100 13f79535-47bb-0310-9956-ffa450edef68 --- core/src/main/java/org/apache/struts2/StrutsConstants.java | 2 ++ .../org/apache/struts2/config/BeanSelectionProvider.java | 7 +++---- core/src/main/resources/struts-default.xml | 1 + .../java/org/apache/struts2/rest/RestActionInvocation.java | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/StrutsConstants.java b/core/src/main/java/org/apache/struts2/StrutsConstants.java index fb4b0012d..8eef187b4 100644 --- a/core/src/main/java/org/apache/struts2/StrutsConstants.java +++ b/core/src/main/java/org/apache/struts2/StrutsConstants.java @@ -193,4 +193,6 @@ public final class StrutsConstants { /** The {@link org.apache.struts2.dispatcher.StaticContentLoader} implementation class */ public static final String STRUTS_STATIC_CONTENT_LOADER = "struts.staticContentLoader"; + /** The {@link com.opensymphony.xwork2.UnknownHandlerManager} implementation class */ + public static final String STRUTS_UNKNOWN_HANDLER_MANAGER = "struts.unknownHandlerManager"; } diff --git a/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java b/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java index 46403f67c..73918f3f6 100644 --- a/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java +++ b/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java @@ -36,6 +36,7 @@ import org.apache.struts2.views.velocity.VelocityManager; import com.opensymphony.xwork2.ActionProxyFactory; import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.TextProvider; +import com.opensymphony.xwork2.UnknownHandlerManager; import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.ConfigurationProvider; @@ -46,10 +47,7 @@ import com.opensymphony.xwork2.inject.ContainerBuilder; import com.opensymphony.xwork2.inject.Context; import com.opensymphony.xwork2.inject.Factory; import com.opensymphony.xwork2.inject.Scope; -import com.opensymphony.xwork2.util.ClassLoaderUtil; -import com.opensymphony.xwork2.util.LocalizedTextUtil; -import com.opensymphony.xwork2.util.PatternMatcher; -import com.opensymphony.xwork2.util.ValueStackFactory; +import com.opensymphony.xwork2.util.*; import com.opensymphony.xwork2.util.location.LocatableProperties; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; @@ -218,6 +216,7 @@ public class BeanSelectionProvider implements ConfigurationProvider { alias(ReflectionContextFactory.class, StrutsConstants.STRUTS_REFLECTIONCONTEXTFACTORY, builder, props); alias(PatternMatcher.class, StrutsConstants.STRUTS_PATTERNMATCHER, builder, props); alias(StaticContentLoader.class, StrutsConstants.STRUTS_STATIC_CONTENT_LOADER, builder, props); + alias(UnknownHandlerManager.class, StrutsConstants.STRUTS_UNKNOWN_HANDLER_MANAGER, builder, props); if ("true".equalsIgnoreCase(props.getProperty(StrutsConstants.STRUTS_DEVMODE))) { props.setProperty(StrutsConstants.STRUTS_I18N_RELOAD, "true"); diff --git a/core/src/main/resources/struts-default.xml b/core/src/main/resources/struts-default.xml index 4bdedf11e..007e212d4 100644 --- a/core/src/main/resources/struts-default.xml +++ b/core/src/main/resources/struts-default.xml @@ -96,6 +96,7 @@ + diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java index de70a8339..118f31309 100644 --- a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java +++ b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java @@ -24,6 +24,7 @@ package org.apache.struts2.rest; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.DefaultActionInvocation; import com.opensymphony.xwork2.Result; +import com.opensymphony.xwork2.UnknownHandlerManager; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.logging.Logger; @@ -81,9 +82,9 @@ public class RestActionInvocation extends DefaultActionInvocation { method = getAction().getClass().getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // well, give the unknown handler a shot - if (unknownHandler != null) { + if (unknownHandlerManager.hasUnknownHandlers()) { try { - methodResult = unknownHandler.handleUnknownActionMethod(action, methodName); + methodResult = unknownHandlerManager.handleUnknownMethod(action, methodName); methodCalled = true; } catch (NoSuchMethodException e2) { // throw the original one