You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mr...@apache.org on 2006/11/18 23:40:19 UTC

svn commit: r476642 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/components/ main/java/org/apache/struts2/dispatcher/ main/java/org/apache/struts2/impl/ main/java/org/apache/struts2/portlet/dispatcher/ main/java/org/apache/struts2/...

Author: mrdon
Date: Sat Nov 18 14:40:18 2006
New Revision: 476642

URL: http://svn.apache.org/viewvc?view=rev&rev=476642
Log:
Matched action proxy handling to xwork changes
XW-440

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java?view=diff&rev=476642&r1=476641&r2=476642
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java Sat Nov 18 14:40:18 2006
@@ -41,7 +41,6 @@
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.ActionProxyFactory;
-import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
@@ -121,7 +120,6 @@
     protected HttpServletRequest req;
 
     protected ActionProxyFactory actionProxyFactory;
-    protected Configuration configuration;
     protected ActionProxy proxy;
     protected String name;
     protected String namespace;
@@ -143,18 +141,6 @@
         this.actionProxyFactory = actionProxyFactory;
     }
 
-
-
-    /**
-     * @param configuration the configuration to set
-     */
-    @Inject
-    public void setConfiguration(Configuration configuration) {
-        this.configuration = configuration;
-    }
-
-
-
     public boolean end(Writer writer, String body) {
         boolean end = super.end(writer, "", false);
         try {
@@ -259,7 +245,7 @@
         // execute at this point, after params have been set
         try {
             
-            proxy = actionProxyFactory.createActionProxy(configuration, namespace, actionName, createExtraContext(), executeResult, true);
+            proxy = actionProxyFactory.createActionProxy(namespace, actionName, createExtraContext(), executeResult, true);
             if (null != methodName) {
                 proxy.setMethod(methodName);
             }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?view=diff&rev=476642&r1=476641&r2=476642
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java Sat Nov 18 14:40:18 2006
@@ -431,7 +431,7 @@
 
             Configuration config = configurationManager.getConfiguration();
             ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy(
-                    config, namespace, name, extraContext, true, false);
+                    namespace, name, extraContext, true, false);
             proxy.setMethod(method);
             request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack());
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java?view=diff&rev=476642&r1=476641&r2=476642
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java Sat Nov 18 14:40:18 2006
@@ -27,16 +27,14 @@
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.DefaultActionProxy;
-import com.opensymphony.xwork2.ObjectFactory;
-import com.opensymphony.xwork2.config.Configuration;
 
 public class StrutsActionProxy extends DefaultActionProxy {
 
     private static final long serialVersionUID = -2434901249671934080L;
 
-    public StrutsActionProxy(ObjectFactory objectFactory, Configuration cfg, String namespace, String actionName, Map extraContext,
+    public StrutsActionProxy(String namespace, String actionName, Map extraContext,
                              boolean executeResult, boolean cleanupContext) throws Exception {
-        super(objectFactory, cfg, namespace, actionName, extraContext, executeResult, cleanupContext);
+        super(namespace, actionName, extraContext, executeResult, cleanupContext);
     }
 
     public String execute() throws Exception {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java?view=diff&rev=476642&r1=476641&r2=476642
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java Sat Nov 18 14:40:18 2006
@@ -26,17 +26,19 @@
 
 import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.DefaultActionProxyFactory;
-import com.opensymphony.xwork2.config.Configuration;
 
 public class StrutsActionProxyFactory extends DefaultActionProxyFactory {
 
-    public ActionProxy createActionProxy(Configuration config, String namespace, String actionName, Map extraContext)
+    public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext)
             throws Exception {
-        return new StrutsActionProxy(objectFactory, config, namespace, actionName, extraContext, true, true);
+        return createActionProxy(namespace, actionName, extraContext, true, true);
     }
 
-    public ActionProxy createActionProxy(Configuration config, String namespace, String actionName, Map extraContext,
+    public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext,
             boolean executeResult, boolean cleanupContext) throws Exception {
-        return new StrutsActionProxy(objectFactory, config, namespace, actionName, extraContext, executeResult, cleanupContext);
+        ActionProxy proxy = new StrutsActionProxy(namespace, actionName, extraContext, executeResult, cleanupContext);
+        container.inject(proxy);
+        proxy.prepare();
+        return proxy;
     }
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java?view=diff&rev=476642&r1=476641&r2=476642
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java Sat Nov 18 14:40:18 2006
@@ -398,8 +398,7 @@
         try {
             LOG.debug("Creating action proxy for name = " + actionName
                     + ", namespace = " + namespace);
-            ActionProxy proxy = factory.createActionProxy(
-                    dispatcherUtils.getConfigurationManager().getConfiguration(), namespace,
+            ActionProxy proxy = factory.createActionProxy(namespace,
                     actionName, extraContext);
             request.setAttribute("struts.valueStack", proxy.getInvocation()
                     .getStack());

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java?view=diff&rev=476642&r1=476641&r2=476642
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java Sat Nov 18 14:40:18 2006
@@ -41,6 +41,7 @@
 import com.opensymphony.xwork2.DefaultActionInvocation;
 import com.opensymphony.xwork2.DefaultActionProxy;
 import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.UnknownHandler;
 import com.opensymphony.xwork2.ValidationAware;
 import com.opensymphony.xwork2.ValidationAwareSupport;
 import com.opensymphony.xwork2.config.Configuration;
@@ -91,8 +92,9 @@
 
         try {
             Configuration cfg = du.getConfigurationManager().getConfiguration();
-            ObjectFactory of = cfg.getContainer().getInstance(ObjectFactory.class);
-            ValidatorActionProxy proxy = new ValidatorActionProxy(of, cfg, namespace, action, ctx);
+            ValidatorActionProxy proxy = new ValidatorActionProxy(namespace, action, ctx);
+            cfg.getContainer().inject(proxy);
+            proxy.prepare();
             proxy.execute();
             Object a = proxy.getAction();
 
@@ -116,8 +118,8 @@
     public static class ValidatorActionInvocation extends DefaultActionInvocation {
         private static final long serialVersionUID = -7645433725470191275L;
 
-        protected ValidatorActionInvocation(ObjectFactory objectFactory, ActionProxy proxy, Map extraContext) throws Exception {
-            super(objectFactory, proxy, extraContext, true);
+        protected ValidatorActionInvocation(ObjectFactory objectFactory, UnknownHandler handler, ActionProxy proxy, Map extraContext) throws Exception {
+            super(objectFactory, handler, proxy, extraContext, true);
         }
 
         protected String invokeAction(Object action, ActionConfig actionConfig) throws Exception {
@@ -128,12 +130,13 @@
     public static class ValidatorActionProxy extends DefaultActionProxy {
         private static final long serialVersionUID = 5754781916414047963L;
 
-        protected ValidatorActionProxy(ObjectFactory objectFactory, Configuration config, String namespace, String actionName, Map extraContext) throws Exception {
-            super(objectFactory, config, namespace, actionName, extraContext, false, true);
+        protected ValidatorActionProxy(String namespace, String actionName, Map extraContext) throws Exception {
+            super(namespace, actionName, extraContext, false, true);
         }
 
-        protected void prepare() throws Exception {
-            invocation = new ValidatorActionInvocation(objectFactory, this, extraContext);
+        public void prepare() throws Exception {
+            super.prepare();
+            invocation = new ValidatorActionInvocation(objectFactory, unknownHandler, this, extraContext);
         }
     }
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java?view=diff&rev=476642&r1=476641&r2=476642
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java Sat Nov 18 14:40:18 2006
@@ -170,15 +170,11 @@
     }
 
     protected ActionProxy buildProxy(String actionName) throws Exception {
-        return container.getInstance(ActionProxyFactory.class).createActionProxy(
-                configurationManager.getConfiguration(), "", actionName, context);
+        return actionProxyFactory.createActionProxy("", actionName, context);
     }
 
     protected void setUp() throws Exception {
-        configurationManager = new ConfigurationManager();
-        configurationManager.addConfigurationProvider(new WaitConfigurationProvider());
-        configurationManager.reload();
-        container = configurationManager.getConfiguration().getContainer();
+        loadConfigurationProviders(new WaitConfigurationProvider());
 
         session = new HashMap();
         params = new HashMap();

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java?view=diff&rev=476642&r1=476641&r2=476642
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java Sat Nov 18 14:40:18 2006
@@ -107,10 +107,7 @@
     }
 
     protected void setUp() throws Exception {
-        configurationManager = new ConfigurationManager();
-        configurationManager.addConfigurationProvider(new TestConfigurationProvider());
-        configurationManager.reload();
-        container = configurationManager.getConfiguration().getContainer();
+        loadConfigurationProviders(new TestConfigurationProvider());
 
         session = new HashMap();
         params = new HashMap();
@@ -131,8 +128,7 @@
     }
 
     protected ActionProxy buildProxy(String actionName) throws Exception {
-        return container.getInstance(ActionProxyFactory.class).createActionProxy(
-                configurationManager.getConfiguration(), "", actionName, extraContext, true, true);
+        return actionProxyFactory.createActionProxy("", actionName, extraContext, true, true);
     }
 
     protected void tearDown() throws Exception {

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java?view=diff&rev=476642&r1=476641&r2=476642
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java Sat Nov 18 14:40:18 2006
@@ -103,7 +103,7 @@
         mockActionProxy = mock(ActionProxy.class);
         mockInvocation = mock(ActionInvocation.class);
 
-        mockActionFactory.expects(once()).method("createActionProxy").with(new Constraint[]{isA(Configuration.class), eq(namespace), eq(actionName), isA(Map.class)}).will(returnValue(mockActionProxy.proxy()));
+        mockActionFactory.expects(once()).method("createActionProxy").with(new Constraint[]{eq(namespace), eq(actionName), isA(Map.class)}).will(returnValue(mockActionProxy.proxy()));
         mockActionProxy.stubs().method("getAction").will(returnValue(mockAction.proxy()));
         mockActionProxy.expects(once()).method("execute").will(returnValue(result));
         mockActionProxy.expects(once()).method("getInvocation").will(returnValue(mockInvocation.proxy()));