struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nil...@apache.org
Subject svn commit: r564599 - in /struts/struts2/trunk: apps/portlet/src/main/webapp/WEB-INF/ plugins/portlet/src/main/java/org/apache/struts2/portlet/context/ plugins/portlet/src/main/java/org/apache/struts2/portlet/result/ plugins/portlet/src/main/java/org/a...
Date Fri, 10 Aug 2007 14:05:19 GMT
Author: nilsga
Date: Fri Aug 10 07:05:17 2007
New Revision: 564599

URL: http://svn.apache.org/viewvc?view=rev&rev=564599
Log:
WW-2101 Removed PreparatorServlet - Replaced by mock servlet implementation classes in org.apache.struts2.portlet.servlet

Removed:
    struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/PreparatorServlet.java
    struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/context/PreparatorServletTest.java
Modified:
    struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/web.xml
    struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
    struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java
    struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
    struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java

Modified: struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/web.xml?view=diff&rev=564599&r1=564598&r2=564599
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/web.xml (original)
+++ struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/web.xml Fri Aug 10 07:05:17
2007
@@ -1,16 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE web-app
-    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
-    "http://java.sun.com/dtd/web-app_2_3.dtd">
-
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
 <web-app id="StrutsPortlet">
-
-    <!-- Uncomment/comment this if you need/don't need Spring support -->
-    <context-param>
-        <param-name>contextConfigLocation</param-name>
-        <param-value>/WEB-INF/applicationContext*.xml</param-value>
-    </context-param>
+	<!-- Uncomment/comment this if you need/don't need Spring support -->
+	<context-param>
+		<param-name>contextConfigLocation</param-name>
+		<param-value>
+			/WEB-INF/applicationContext*.xml
+		</param-value>
+	</context-param>
 
     <filter id="filterdispatcher">
         <filter-name>Struts2</filter-name>
@@ -21,28 +18,11 @@
         <filter-name>Struts2</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
+	
+	<listener>
+		<listener-class> org.springframework.web.context.ContextLoaderListener
+			</listener-class>
+	</listener>
 
-    <listener>
-        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
-    </listener>
-
-    <listener>
-        <listener-class>org.apache.struts2.portlet.context.ServletContextHolderListener</listener-class>
-    </listener>
-
-    <servlet id="preparator">
-        <servlet-name>preparator</servlet-name>
-        <servlet-class>org.apache.struts2.portlet.context.PreparatorServlet</servlet-class>
-    </servlet>
-
-    <servlet id="dwr">
-        <servlet-name>dwr</servlet-name>
-        <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>dwr</servlet-name>
-        <url-pattern>/dwr/*</url-pattern>
-    </servlet-mapping>
 
 </web-app>

Modified: struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java?view=diff&rev=564599&r1=564598&r2=564599
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
Fri Aug 10 07:05:17 2007
@@ -180,20 +180,6 @@
             res.setTitle(title);
         }
         LOG.debug("Location: " + finalLocation);
-        PortletRequestDispatcher preparator = cfg.getPortletContext()
-                .getNamedDispatcher("preparator");
-        if(preparator == null) {
-            throw new PortletException("Cannot look up 'preparator' servlet. Make sure that
you" +
-                    "have configured it correctly in the web.xml file.");
-        }
-        new IncludeTemplate() {
-            protected void when(PortletException e) {
-                LOG.error("PortletException while dispatching to 'preparator' servlet", e);
-            }
-            protected void when(IOException e) {
-                LOG.error("IOException while dispatching to 'preparator' servlet", e);
-            }
-        }.include(preparator, req, res);
         PortletRequestDispatcher dispatcher = cfg.getPortletContext().getRequestDispatcher(finalLocation);
         if(dispatcher == null) {
             throw new PortletException("Could not locate dispatcher for '" + finalLocation
+ "'");

Modified: struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java?view=diff&rev=564599&r1=564598&r2=564599
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java
Fri Aug 10 07:05:17 2007
@@ -99,7 +99,6 @@
     
     private String defaultEncoding;
     private VelocityManager velocityManager;
-    
     public PortletVelocityResult() {
         super();
     }
@@ -160,7 +159,6 @@
      */
     public void executeRenderResult(String finalLocation,
             ActionInvocation invocation) throws Exception {
-        prepareServletActionContext();
         ValueStack stack = ActionContext.getContext().getValueStack();
 
         HttpServletRequest request = ServletActionContext.getRequest();
@@ -192,7 +190,7 @@
             if (encoding != null) {
                 contentType = contentType + ";charset=" + encoding;
             }
-
+            response.setContentType(contentType);
             Template t = getTemplate(stack,
                     velocityManager.getVelocityEngine(), invocation,
                     finalLocation, encoding);
@@ -202,8 +200,6 @@
             Writer writer = new OutputStreamWriter(response.getOutputStream(),
                     encoding);
 
-            response.setContentType(contentType);
-
             t.merge(context, writer);
 
             // always flush the writer (we used to only flush it if this was a
@@ -292,16 +288,5 @@
             ValueStack stack, HttpServletRequest request,
             HttpServletResponse response, String location) {
         return velocityManager.createContext(stack, request, response);
-    }
-
-    /**
-     *  Prepares the servlet action context for this request
-     */
-    private void prepareServletActionContext() throws PortletException,
-            IOException {
-        PortletRequestDispatcher disp = PortletActionContext.getPortletConfig()
-                .getPortletContext().getNamedDispatcher("preparator");
-        disp.include(PortletActionContext.getRenderRequest(),
-                PortletActionContext.getRenderResponse());
     }
 }

Modified: struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java?view=diff&rev=564599&r1=564598&r2=564599
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
Fri Aug 10 07:05:17 2007
@@ -136,7 +136,6 @@
     private void executeRenderResult(String location,
                                      ActionInvocation invocation) throws TemplateException,
IOException,
             TemplateModelException, PortletException {
-        prepareServletActionContext();
         this.location = location;
         this.invocation = invocation;
         this.configuration = getConfiguration();
@@ -162,17 +161,6 @@
                 postTemplateProcess(template, model);
             }
         }
-    }
-
-    /**
-     *
-     */
-    private void prepareServletActionContext() throws PortletException,
-            IOException {
-        PortletRequestDispatcher disp = PortletActionContext.getPortletConfig()
-                .getPortletContext().getNamedDispatcher("preparator");
-        disp.include(PortletActionContext.getRenderRequest(),
-                PortletActionContext.getRenderResponse());
     }
 
     /**

Modified: struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java?view=diff&rev=564599&r1=564598&r2=564599
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
Fri Aug 10 07:05:17 2007
@@ -80,7 +80,6 @@
         Mock mockRequest = mock(RenderRequest.class);
         Mock mockResponse = mock(RenderResponse.class);
         Mock mockRd = mock(PortletRequestDispatcher.class);
-        Mock mockPrep = mock(PortletRequestDispatcher.class);
 
         RenderRequest req = (RenderRequest)mockRequest.proxy();
         RenderResponse res = (RenderResponse)mockResponse.proxy();
@@ -91,9 +90,7 @@
 
         Constraint[] params = new Constraint[]{same(req), same(res)};
         mockRd.expects(once()).method("include").with(params);
-        mockPrep.expects(once()).method("include").with(params);
         mockCtx.expects(once()).method("getRequestDispatcher").with(eq("/WEB-INF/pages/testPage.jsp")).will(returnValue(rd));
-        mockCtx.expects(once()).method("getNamedDispatcher").with(eq("preparator")).will(returnValue(mockPrep.proxy()));
         mockResponse.expects(once()).method("setContentType").with(eq("text/html"));
         mockConfig.expects(once()).method("getPortletContext").will(returnValue(ctx));
 
@@ -207,7 +204,6 @@
         Mock mockRequest = mock(RenderRequest.class);
         Mock mockResponse = mock(RenderResponse.class);
         Mock mockRd = mock(PortletRequestDispatcher.class);
-        Mock mockPrep = mock(PortletRequestDispatcher.class);
 
         RenderRequest req = (RenderRequest)mockRequest.proxy();
         RenderResponse res = (RenderResponse)mockResponse.proxy();
@@ -217,9 +213,7 @@
 
         Constraint[] params = new Constraint[]{same(req), same(res)};
         mockRd.expects(once()).method("include").with(params);
-        mockPrep.expects(once()).method("include").with(params);
         mockCtx.expects(once()).method("getRequestDispatcher").with(eq("/WEB-INF/pages/testPage.jsp")).will(returnValue(rd));
-        mockCtx.expects(once()).method("getNamedDispatcher").with(eq("preparator")).will(returnValue(mockPrep.proxy()));
         mockConfig.expects(once()).method("getPortletContext").will(returnValue(ctx));
 
         mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));



Mime
View raw message