struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r674498 - in /struts/struts2/trunk: apps/blank/src/main/webapp/WEB-INF/ apps/mailreader/src/main/webapp/WEB-INF/ apps/rest-showcase/src/main/webapp/WEB-INF/ apps/showcase/src/main/webapp/WEB-INF/ core/src/main/java/org/apache/struts2/dispat...
Date Mon, 07 Jul 2008 14:10:43 GMT
Author: mrdon
Date: Mon Jul  7 07:10:42 2008
New Revision: 674498

URL: http://svn.apache.org/viewvc?rev=674498&view=rev
Log:
Repackaging new dispatchers, adding "unsupported" servlet dispatcher, fixing a spring issue
where
it was needlessly tied to WebApplicationContext and a rest issue where the autowiring of returned
result objects wasn't copied into the rest plugin from xwork
WW-2193

Added:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/HostConfig.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/FilterHostConfig.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java
      - copied, changed from r674291, struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsExecuteFilter.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
      - copied, changed from r674291, struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilter.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
      - copied, changed from r674291, struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareFilter.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/ServletHostConfig.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Removed:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsExecuteFilter.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilter.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareFilter.java
Modified:
    struts/struts2/trunk/apps/blank/src/main/webapp/WEB-INF/web.xml
    struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml
    struts/struts2/trunk/apps/rest-showcase/src/main/webapp/WEB-INF/web.xml
    struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StaticContentLoader.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilterIntegrationTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/TwoFilterIntegrationTest.java
    struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java
    struts/struts2/trunk/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java

Modified: struts/struts2/trunk/apps/blank/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/WEB-INF/web.xml?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/webapp/WEB-INF/web.xml (original)
+++ struts/struts2/trunk/apps/blank/src/main/webapp/WEB-INF/web.xml Mon Jul  7 07:10:42 2008
@@ -5,7 +5,7 @@
 
     <filter>
         <filter-name>struts2</filter-name>
-        <filter-class>org.apache.struts2.dispatcher.ng.StrutsPrepareAndExecuteFilter</filter-class>
+        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
     </filter>
 
     <filter-mapping>

Modified: struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml Mon Jul  7 07:10:42
2008
@@ -7,7 +7,7 @@
     <filter>
         <filter-name>Struts2</filter-name>
         <filter-class>
-            org.apache.struts2.dispatcher.ng.StrutsPrepareAndExecuteFilter
+            org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
         </filter-class>
     </filter>
 

Modified: struts/struts2/trunk/apps/rest-showcase/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/rest-showcase/src/main/webapp/WEB-INF/web.xml?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/apps/rest-showcase/src/main/webapp/WEB-INF/web.xml (original)
+++ struts/struts2/trunk/apps/rest-showcase/src/main/webapp/WEB-INF/web.xml Mon Jul  7 07:10:42
2008
@@ -12,7 +12,7 @@
   <!-- START SNIPPET: filter -->
     <filter>
         <filter-name>action2</filter-name>
-        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
+        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
         <init-param>
           <param-name>actionPackages</param-name>
           <param-value>org.apache.struts2.rest.example</param-value>

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml Mon Jul  7 07:10:42
2008
@@ -8,7 +8,7 @@
 	
     <filter>
         <filter-name>struts-prepare</filter-name>
-        <filter-class>org.apache.struts2.dispatcher.ng.StrutsPrepareFilter</filter-class>
+        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
         <init-param>
         	<param-name>actionPackages</param-name>
         	<param-value>org.apache.struts2.showcase.person</param-value>
@@ -17,7 +17,7 @@
 
     <filter>
         <filter-name>struts-execute</filter-name>
-        <filter-class>org.apache.struts2.dispatcher.ng.StrutsExecuteFilter</filter-class>
+        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
     </filter>
 
     <filter>

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
Mon Jul  7 07:10:42 2008
@@ -59,13 +59,13 @@
  * <!-- SNIPPET END: description -->
  *
  *
- * @deprecated Since Struts 2.1.3, use {@link org.apache.struts2.dispatcher.ng.StrutsPrepareFilter}
and
- * {@link org.apache.struts2.dispatcher.ng.StrutsExecuteFilter} to use other Servlet filters
that need access to
+ * @deprecated Since Struts 2.1.3, use {@link org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter}
and
+ * {@link org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter} to use other Servlet
filters that need access to
  * the ActionContext
  * @see FilterDispatcher
  * @see Dispatcher
- * @see org.apache.struts2.dispatcher.ng.StrutsPrepareFilter
- * @see org.apache.struts2.dispatcher.ng.StrutsExecuteFilter
+ * @see org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
+ * @see org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
  *
  * @version $Date$ $Id$
  */

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
Mon Jul  7 07:10:42 2008
@@ -35,6 +35,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.dispatcher.ng.HostConfig;
 import org.apache.struts2.util.ClassLoaderUtils;
 
 import com.opensymphony.xwork2.inject.Inject;
@@ -109,9 +110,9 @@
     /*
      * (non-Javadoc)
      *
-     * @see org.apache.struts2.dispatcher.StaticResourceLoader#setFilterConfig(javax.servlet.FilterConfig)
+     * @see org.apache.struts2.dispatcher.StaticResourceLoader#setHostConfig(javax.servlet.FilterConfig)
      */
-    public void setFilterConfig(FilterConfig filterConfig) {
+    public void setHostConfig(HostConfig filterConfig) {
         String param = filterConfig.getInitParameter("packages");
         String packages = getAdditionalPackages();
         if (param != null) {
@@ -227,7 +228,7 @@
         }
     }
 
-    private void initLogging(FilterConfig filterConfig) {
+    private void initLogging(HostConfig filterConfig) {
         String factoryName = filterConfig.getInitParameter("loggerFactory");
         if (factoryName != null) {
             try {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
Mon Jul  7 07:10:42 2008
@@ -40,6 +40,7 @@
 import org.apache.struts2.StrutsStatics;
 import org.apache.struts2.dispatcher.mapper.ActionMapper;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.apache.struts2.dispatcher.ng.filter.FilterHostConfig;
 import org.apache.struts2.util.ClassLoaderUtils;
 
 import com.opensymphony.xwork2.ActionContext;
@@ -136,15 +137,15 @@
  * the subclass.
  *
  * @version $Date$ $Id$
- * @deprecated Since Struts 2.1.3, use {@link org.apache.struts2.dispatcher.ng.StrutsPrepareAndExecuteFilter}
instead or
- * {@link org.apache.struts2.dispatcher.ng.StrutsPrepareFilter} and {@link org.apache.struts2.dispatcher.ng.StrutsExecuteFilter}
+ * @deprecated Since Struts 2.1.3, use {@link org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter}
instead or
+ * {@link org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter} and {@link org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter}
  * if needing using the {@link ActionContextCleanUp} filter in addition to this one
  *
  * @see ActionMapper
  * @see ActionContextCleanUp
- * @see org.apache.struts2.dispatcher.ng.StrutsPrepareAndExecuteFilter
- * @see org.apache.struts2.dispatcher.ng.StrutsPrepareFilter
- * @see org.apache.struts2.dispatcher.ng.StrutsExecuteFilter
+ * @see org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
+ * @see org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
+ * @see org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
  */
 public class FilterDispatcher implements StrutsStatics, Filter {
 
@@ -189,7 +190,7 @@
             dispatcher.init();
             dispatcher.getContainer().inject(this);
 
-            staticResourceLoader.setFilterConfig(filterConfig);
+            staticResourceLoader.setHostConfig(new FilterHostConfig(filterConfig));
         } finally {
             ActionContext.setContext(null);
         }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StaticContentLoader.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StaticContentLoader.java?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StaticContentLoader.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StaticContentLoader.java
Mon Jul  7 07:10:42 2008
@@ -20,6 +20,8 @@
  */
 package org.apache.struts2.dispatcher;
 
+import org.apache.struts2.dispatcher.ng.HostConfig;
+
 import java.io.IOException;
 
 import javax.servlet.FilterConfig;
@@ -43,7 +45,7 @@
      * @param filterConfig
      *            The filter configuration
      */
-    public abstract void setFilterConfig(FilterConfig filterConfig);
+    public abstract void setHostConfig(HostConfig filterConfig);
 
     /**
      * Locate a static resource and copy directly to the response, setting the

Added: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/HostConfig.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/HostConfig.java?rev=674498&view=auto
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/HostConfig.java
(added)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/HostConfig.java
Mon Jul  7 07:10:42 2008
@@ -0,0 +1,46 @@
+/*
+ * $Id: DefaultActionSupport.java 651946 2008-04-27 13:41:38Z apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.dispatcher.ng;
+
+import javax.servlet.ServletContext;
+import java.util.Iterator;
+
+/**
+ * Abstraction for host configuration information such as init params or the servlet context.
+ */
+public interface HostConfig {
+
+    /**
+     * @param key The parameter key
+     * @return The parameter value
+     */
+    String getInitParameter(String key);
+
+    /**
+     * @return A list of parameter names
+     */
+    Iterator<String> getInitParameterNames();
+
+    /**
+     * @return The servlet context
+     */
+    ServletContext getServletContext();
+}

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java
Mon Jul  7 07:10:42 2008
@@ -26,10 +26,9 @@
 import org.apache.struts2.dispatcher.StaticContentLoader;
 import org.apache.struts2.util.ClassLoaderUtils;
 
-import javax.servlet.FilterConfig;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Iterator;
 
 /**
  * Contains initialization operations
@@ -42,7 +41,7 @@
     /**
      * Initializes the internal Struts logging
      */
-    public void initLogging(FilterConfig filterConfig) {
+    public void initLogging(HostConfig filterConfig) {
         String factoryName = filterConfig.getInitParameter("loggerFactory");
         if (factoryName != null) {
             try {
@@ -65,7 +64,7 @@
     /**
      * Creates and initializes the dispatcher
      */
-    public Dispatcher initDispatcher(FilterConfig filterConfig) {
+    public Dispatcher initDispatcher(HostConfig filterConfig) {
         Dispatcher dispatcher = createDispatcher(filterConfig);
         dispatcher.init();
         return dispatcher;
@@ -74,9 +73,9 @@
     /**
      * Initializes the static content loader with the filter configuration
      */
-    public StaticContentLoader initStaticContentLoader(FilterConfig filterConfig, Dispatcher
dispatcher) {
+    public StaticContentLoader initStaticContentLoader(HostConfig filterConfig, Dispatcher
dispatcher) {
         StaticContentLoader loader = dispatcher.getContainer().getInstance(StaticContentLoader.class);
-        loader.setFilterConfig(filterConfig);
+        loader.setHostConfig(filterConfig);
         return loader;
     }
 
@@ -95,10 +94,10 @@
     /**
      * Create a {@link Dispatcher} 
      */
-    private Dispatcher createDispatcher(FilterConfig filterConfig) {
+    private Dispatcher createDispatcher(HostConfig filterConfig) {
         Map<String, String> params = new HashMap<String, String>();
-        for (Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements();)
{
-            String name = (String) e.nextElement();
+        for (Iterator e = filterConfig.getInitParameterNames(); e.hasNext();) {
+            String name = (String) e.next();
             String value = filterConfig.getInitParameter(name);
             params.put(name, value);
         }

Added: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/FilterHostConfig.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/FilterHostConfig.java?rev=674498&view=auto
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/FilterHostConfig.java
(added)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/FilterHostConfig.java
Mon Jul  7 07:10:42 2008
@@ -0,0 +1,52 @@
+/*
+ * $Id: DefaultActionSupport.java 651946 2008-04-27 13:41:38Z apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.dispatcher.ng.filter;
+
+import com.opensymphony.xwork2.util.EnumerationIterator;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import java.util.Iterator;
+
+import org.apache.struts2.dispatcher.ng.HostConfig;
+
+/**
+ * Host configuration that wraps FilterConfig
+ */
+public class FilterHostConfig implements HostConfig {
+
+    private FilterConfig config;
+
+    public FilterHostConfig(FilterConfig config) {
+        this.config = config;
+    }
+    public String getInitParameter(String key) {
+        return config.getInitParameter(key);
+    }
+
+    public Iterator<String> getInitParameterNames() {
+        return new EnumerationIterator(config.getInitParameterNames());
+    }
+
+    public ServletContext getServletContext() {
+        return config.getServletContext();
+    }
+}

Copied: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java
(from r674291, struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsExecuteFilter.java)
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java?p2=struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java&p1=struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsExecuteFilter.java&r1=674291&r2=674498&rev=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsExecuteFilter.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java
Mon Jul  7 07:10:42 2008
@@ -18,10 +18,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.struts2.dispatcher.ng;
+package org.apache.struts2.dispatcher.ng.filter;
 
 import org.apache.struts2.StrutsStatics;
 import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.ng.PrepareOperations;
+import org.apache.struts2.dispatcher.ng.ExecuteOperations;
+import org.apache.struts2.dispatcher.ng.InitOperations;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 
 import javax.servlet.*;
@@ -47,7 +50,7 @@
         if (execute == null) {
             InitOperations init = new InitOperations();
             Dispatcher dispatcher = init.findDispatcherOnThread();
-            init.initStaticContentLoader(filterConfig, dispatcher);
+            init.initStaticContentLoader(new FilterHostConfig(filterConfig), dispatcher);
 
             prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher);
             execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher);

Copied: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
(from r674291, struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilter.java)
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java?p2=struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java&p1=struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilter.java&r1=674291&r2=674498&rev=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilter.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
Mon Jul  7 07:10:42 2008
@@ -18,10 +18,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.struts2.dispatcher.ng;
+package org.apache.struts2.dispatcher.ng.filter;
 
 import org.apache.struts2.StrutsStatics;
 import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.ng.PrepareOperations;
+import org.apache.struts2.dispatcher.ng.ExecuteOperations;
+import org.apache.struts2.dispatcher.ng.InitOperations;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 
 import javax.servlet.*;
@@ -40,9 +43,10 @@
     public void init(FilterConfig filterConfig) throws ServletException {
         InitOperations init = new InitOperations();
         try {
-            init.initLogging(filterConfig);
-            Dispatcher dispatcher = init.initDispatcher(filterConfig);
-            init.initStaticContentLoader(filterConfig, dispatcher);
+            FilterHostConfig config = new FilterHostConfig(filterConfig);
+            init.initLogging(config);
+            Dispatcher dispatcher = init.initDispatcher(config);
+            init.initStaticContentLoader(config, dispatcher);
 
             prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher);
             execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher);

Copied: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
(from r674291, struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareFilter.java)
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java?p2=struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java&p1=struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareFilter.java&r1=674291&r2=674498&rev=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/StrutsPrepareFilter.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
Mon Jul  7 07:10:42 2008
@@ -18,10 +18,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.struts2.dispatcher.ng;
+package org.apache.struts2.dispatcher.ng.filter;
 
 import org.apache.struts2.StrutsStatics;
 import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.ng.PrepareOperations;
+import org.apache.struts2.dispatcher.ng.InitOperations;
 
 import javax.servlet.*;
 import javax.servlet.http.HttpServletRequest;
@@ -29,7 +31,7 @@
 import java.io.IOException;
 
 /**
- * Prepares the request for execution by a later {@link StrutsExecuteFilter} filter instance.
+ * Prepares the request for execution by a later {@link org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter}
filter instance.
  */
 public class StrutsPrepareFilter implements StrutsStatics, Filter {
     private PrepareOperations prepare;
@@ -37,8 +39,9 @@
     public void init(FilterConfig filterConfig) throws ServletException {
         InitOperations init = new InitOperations();
         try {
-            init.initLogging(filterConfig);
-            Dispatcher dispatcher = init.initDispatcher(filterConfig);
+            FilterHostConfig config = new FilterHostConfig(filterConfig);
+            init.initLogging(config);
+            Dispatcher dispatcher = init.initDispatcher(config);
 
             prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher);
         } finally {

Added: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/ServletHostConfig.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/ServletHostConfig.java?rev=674498&view=auto
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/ServletHostConfig.java
(added)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/ServletHostConfig.java
Mon Jul  7 07:10:42 2008
@@ -0,0 +1,51 @@
+/*
+ * $Id: DefaultActionSupport.java 651946 2008-04-27 13:41:38Z apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.dispatcher.ng.servlet;
+
+import com.opensymphony.xwork2.util.EnumerationIterator;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import java.util.Iterator;
+
+import org.apache.struts2.dispatcher.ng.HostConfig;
+
+/**
+ * Host configuration that wraps a ServletConfig
+ */
+public class ServletHostConfig implements HostConfig {
+    private ServletConfig config;
+
+    public ServletHostConfig(ServletConfig config) {
+        this.config = config;
+    }
+    public String getInitParameter(String key) {
+        return config.getInitParameter(key);
+    }
+
+    public Iterator<String> getInitParameterNames() {
+        return new EnumerationIterator(config.getInitParameterNames());
+    }
+
+    public ServletContext getServletContext() {
+        return config.getServletContext();
+    }
+}

Added: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java?rev=674498&view=auto
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
(added)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Mon Jul  7 07:10:42 2008
@@ -0,0 +1,87 @@
+/*
+ * $Id: DefaultActionSupport.java 651946 2008-04-27 13:41:38Z apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.dispatcher.ng.servlet;
+
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.ng.InitOperations;
+import org.apache.struts2.dispatcher.ng.PrepareOperations;
+import org.apache.struts2.dispatcher.ng.ExecuteOperations;
+import org.apache.struts2.dispatcher.mapper.ActionMapping;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.*;
+import java.io.IOException;
+
+/**
+ * Servlet dispatcher for Struts.  The preferred way to use Struts is as a filter via the
+ * {@link org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter} and its
variants.  This servlet dispatcher
+ * is only for those that really know what they are doing as it may not support every feature
of Struts, particularly
+ * static resource serving.
+ */
+public class StrutsServlet extends HttpServlet {
+
+    private PrepareOperations prepare;
+    private ExecuteOperations execute;
+
+    @Override
+    public void init(ServletConfig filterConfig) throws ServletException {
+        InitOperations init = new InitOperations();
+        try {
+            ServletHostConfig config = new ServletHostConfig(filterConfig);
+            init.initLogging(config);
+            Dispatcher dispatcher = init.initDispatcher(config);
+            init.initStaticContentLoader(config, dispatcher);
+
+            prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher);
+            execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher);
+        } finally {
+            init.cleanup();
+        }
+    }
+
+    @Override
+    public void service(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException {
+
+        try {
+            prepare.createActionContext(request);
+            prepare.assignDispatcherToThread();
+            prepare.setEncodingAndLocale(request, response);
+            request = prepare.wrapRequest(request);
+            ActionMapping mapping = prepare.findActionMapping(request, response);
+            if (mapping == null) {
+                boolean handled = execute.executeStaticResourceRequest(request, response);
+                if (!handled)
+                    throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter
instead.");
+            } else {
+                execute.executeAction(request, response, mapping);
+            }
+        } finally {
+            prepare.cleanupRequest(request);
+        }
+    }
+
+    @Override
+    public void destroy() {
+        prepare.cleanupDispatcher();
+    }
+}

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilterIntegrationTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilterIntegrationTest.java?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilterIntegrationTest.java
(original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/StrutsPrepareAndExecuteFilterIntegrationTest.java
Mon Jul  7 07:10:42 2008
@@ -23,6 +23,7 @@
 import com.opensymphony.xwork2.ActionContext;
 import junit.framework.TestCase;
 import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;
 import org.springframework.mock.web.MockFilterChain;
 import org.springframework.mock.web.MockFilterConfig;
 import org.springframework.mock.web.MockHttpServletRequest;

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/TwoFilterIntegrationTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/TwoFilterIntegrationTest.java?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/TwoFilterIntegrationTest.java
(original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ng/TwoFilterIntegrationTest.java
Mon Jul  7 07:10:42 2008
@@ -23,6 +23,8 @@
 import com.opensymphony.xwork2.ActionContext;
 import junit.framework.TestCase;
 import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter;
+import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter;
 import org.springframework.mock.web.*;
 
 import javax.servlet.*;

Modified: struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java
(original)
+++ struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java
Mon Jul  7 07:10:42 2008
@@ -125,6 +125,8 @@
     protected String processResult(ActionConfig actionConfig, Object methodResult) throws
IOException {
         if (methodResult instanceof Result) {
             this.explicitResult = (Result) methodResult;
+            // Wire the result automatically
+            container.inject(explicitResult);
             return null;
         } else if (methodResult != null) {
             resultCode = handlerSelector.handleResult(actionConfig, methodResult, action);

Modified: struts/struts2/trunk/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java?rev=674498&r1=674497&r2=674498&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
(original)
+++ struts/struts2/trunk/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
Mon Jul  7 07:10:42 2008
@@ -27,6 +27,7 @@
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.web.context.support.WebApplicationContextUtils;
+import org.springframework.web.context.WebApplicationContext;
 
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.spring.SpringObjectFactory;
@@ -72,7 +73,7 @@
         boolean useClassCache = "true".equals(useClassCacheStr);
         LOG.info("Initializing Struts-Spring integration...");
 
-        ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
+        ApplicationContext appContext = (ApplicationContext) servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
         if (appContext == null) {
             // uh oh! looks like the lifecycle listener wasn't installed. Let's inform the
user
             String message = "********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION
**********\n" +



Mime
View raw message