]> source.dussan.org Git - vaadin-framework.git/commitdiff
Use WrappedResponse instead of AbstractCommunicationManager.Response
authorLeif Åstrand <leif@vaadin.com>
Tue, 8 Nov 2011 12:37:22 +0000 (14:37 +0200)
committerLeif Åstrand <leif@vaadin.com>
Tue, 8 Nov 2011 12:37:22 +0000 (14:37 +0200)
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/terminal/gwt/server/CommunicationManager.java
src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java

index 0e2aed6f2846b90b09f38f722866bfb74a30e0a1..5c5604a09fc2f456e75106cd32483f97b6aca1a7 100644 (file)
@@ -41,9 +41,6 @@ import java.util.UUID;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.portlet.PortletResponse;
-import javax.servlet.ServletResponse;
-
 import com.vaadin.Application;
 import com.vaadin.Application.SystemMessages;
 import com.vaadin.terminal.PaintException;
@@ -95,45 +92,6 @@ public abstract class AbstractCommunicationManager implements
 
     private static final RequestHandler APP_RESOURCE_HANDLER = new ApplicationResourceHandler();
 
-    /**
-     * Generic interface of a (HTTP or Portlet) response from the application.
-     * 
-     * This is a wrapper interface that allows
-     * {@link AbstractCommunicationManager} to use a unified API.
-     * 
-     * @see javax.servlet.ServletResponse
-     * @see javax.portlet.PortletResponse
-     * 
-     * @author peholmst
-     */
-    public interface Response extends WrappedResponse {
-
-        /**
-         * Gets the output stream to which the response can be written.
-         * 
-         * @return
-         * @throws IOException
-         */
-        public OutputStream getOutputStream() throws IOException;
-
-        /**
-         * Sets the MIME content type for the response to be communicated to the
-         * browser.
-         * 
-         * @param type
-         */
-        public void setContentType(String type);
-
-        /**
-         * Gets the wrapped response object, usually a class implementing either
-         * {@link ServletResponse} or {@link PortletResponse}.
-         * 
-         * @return wrapped request object
-         */
-        public Object getWrappedResponse();
-
-    }
-
     /**
      * TODO Document me!
      * 
@@ -142,8 +100,8 @@ public abstract class AbstractCommunicationManager implements
     public interface Callback {
 
         public void criticalNotification(WrappedRequest request,
-                Response response, String cap, String msg, String details,
-                String outOfSyncURL) throws IOException;
+                WrappedResponse response, String cap, String msg,
+                String details, String outOfSyncURL) throws IOException;
 
         public String getRequestPathInfo(WrappedRequest request);
 
@@ -277,7 +235,7 @@ public abstract class AbstractCommunicationManager implements
      * @throws IOException
      */
     protected void doHandleSimpleMultipartFileUpload(WrappedRequest request,
-            Response response, StreamVariable streamVariable,
+            WrappedResponse response, StreamVariable streamVariable,
             String variableName, VariableOwner owner, String boundary)
             throws IOException {
         // multipart parsing, supports only one file for request, but that is
@@ -376,7 +334,7 @@ public abstract class AbstractCommunicationManager implements
      * @throws IOException
      */
     protected void doHandleXhrFilePost(WrappedRequest request,
-            Response response, StreamVariable streamVariable,
+            WrappedResponse response, StreamVariable streamVariable,
             String variableName, VariableOwner owner, int contentLength)
             throws IOException {
 
@@ -548,8 +506,8 @@ public abstract class AbstractCommunicationManager implements
      * @param response
      * @throws IOException
      */
-    protected void sendUploadResponse(WrappedRequest request, Response response)
-            throws IOException {
+    protected void sendUploadResponse(WrappedRequest request,
+            WrappedResponse response) throws IOException {
         response.setContentType("text/html");
         final OutputStream out = response.getOutputStream();
         final PrintWriter outWriter = new PrintWriter(new BufferedWriter(
@@ -584,7 +542,7 @@ public abstract class AbstractCommunicationManager implements
      * @throws InvalidUIDLSecurityKeyException
      */
     protected void doHandleUidlRequest(WrappedRequest request,
-            Response response, Callback callback, Root root)
+            WrappedResponse response, Callback callback, Root root)
             throws IOException, InvalidUIDLSecurityKeyException {
 
         requestThemeName = request.getParameter("theme");
@@ -750,7 +708,7 @@ public abstract class AbstractCommunicationManager implements
      * @throws IOException
      */
     private void paintAfterVariableChanges(WrappedRequest request,
-            Response response, Callback callback, boolean repaintAll,
+            WrappedResponse response, Callback callback, boolean repaintAll,
             final PrintWriter outWriter, Root root, boolean analyzeLayouts)
             throws PaintException, IOException {
 
@@ -1144,9 +1102,10 @@ public abstract class AbstractCommunicationManager implements
      * 
      * @return true if successful, false if there was an inconsistency
      */
-    private boolean handleVariables(WrappedRequest request, Response response,
-            Callback callback, Application application2, Root root)
-            throws IOException, InvalidUIDLSecurityKeyException {
+    private boolean handleVariables(WrappedRequest request,
+            WrappedResponse response, Callback callback,
+            Application application2, Root root) throws IOException,
+            InvalidUIDLSecurityKeyException {
         boolean success = true;
 
         String changes = getRequestPayload(request);
@@ -1823,8 +1782,9 @@ public abstract class AbstractCommunicationManager implements
      * @throws IOException
      *             if the writing failed due to input/output error.
      */
-    private void endApplication(WrappedRequest request, Response response,
-            Application application) throws IOException {
+    private void endApplication(WrappedRequest request,
+            WrappedResponse response, Application application)
+            throws IOException {
 
         String logoutUrl = application.getLogoutURL();
         if (logoutUrl == null) {
@@ -1855,7 +1815,8 @@ public abstract class AbstractCommunicationManager implements
      * @param outWriter
      * @param response
      */
-    protected void openJsonMessage(PrintWriter outWriter, Response response) {
+    protected void openJsonMessage(PrintWriter outWriter,
+            WrappedResponse response) {
         // Sets the response type
         response.setContentType("application/json; charset=UTF-8");
         // some dirt to prevent cross site scripting
index c36ae05a2fc1ac956c9b3b0ce386e388bceda2fe..fd97f9e0ea94dc5f47da2d4df6685f7523dc1352 100644 (file)
@@ -21,6 +21,7 @@ import com.vaadin.terminal.Paintable;
 import com.vaadin.terminal.StreamVariable;
 import com.vaadin.terminal.VariableOwner;
 import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.terminal.WrappedResponse;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.Root;
 
@@ -45,7 +46,7 @@ public class CommunicationManager extends AbstractCommunicationManager {
      * 
      * @see Response
      */
-    private static class HttpServletResponseWrapper implements Response {
+    private static class HttpServletResponseWrapper implements WrappedResponse {
 
         private final HttpServletResponse response;
 
@@ -57,7 +58,7 @@ public class CommunicationManager extends AbstractCommunicationManager {
             return response.getOutputStream();
         }
 
-        public Object getWrappedResponse() {
+        public HttpServletResponse getHttpServletResponse() {
             return response;
         }
 
@@ -89,11 +90,13 @@ public class CommunicationManager extends AbstractCommunicationManager {
         }
 
         public void criticalNotification(WrappedRequest request,
-                Response response, String cap, String msg, String details,
-                String outOfSyncURL) throws IOException {
+                WrappedResponse response, String cap, String msg,
+                String details, String outOfSyncURL) throws IOException {
             servlet.criticalNotification(((WrappedHttpServletRequest) request)
-                    .getHttpServletRequest(), (HttpServletResponse) response
-                    .getWrappedResponse(), cap, msg, details, outOfSyncURL);
+                    .getHttpServletRequest(),
+                    ((HttpServletResponseWrapper) response)
+                            .getHttpServletResponse(), cap, msg, details,
+                    outOfSyncURL);
         }
 
         public String getRequestPathInfo(WrappedRequest request) {
index c4995478182ac99bb4b86589ca6dbd4f621c32f4..89ce1e4d2c9ef7d7c2acff9923bd25d7dd9b99b8 100644 (file)
@@ -23,6 +23,7 @@ import com.vaadin.terminal.Paintable;
 import com.vaadin.terminal.StreamVariable;
 import com.vaadin.terminal.VariableOwner;
 import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.terminal.WrappedResponse;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.Root;
 
@@ -37,7 +38,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
 
     private transient ResourceResponse currentUidlResponse;
 
-    private static class PortletResponseWrapper implements Response {
+    private static class PortletResponseWrapper implements WrappedResponse {
 
         private final PortletResponse response;
 
@@ -49,8 +50,8 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
             return ((MimeResponse) response).getPortletOutputStream();
         }
 
-        public Object getWrappedResponse() {
-            return response;
+        public MimeResponse getPortletResponse() {
+            return (MimeResponse) response;
         }
 
         public void setContentType(String type) {
@@ -81,12 +82,12 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
         }
 
         public void criticalNotification(WrappedRequest request,
-                Response response, String cap, String msg, String details,
-                String outOfSyncURL) throws IOException {
+                WrappedResponse response, String cap, String msg,
+                String details, String outOfSyncURL) throws IOException {
             portlet.criticalNotification(
                     ((WrappedPortletRequest) request).getPortletRequest(),
-                    (MimeResponse) response.getWrappedResponse(), cap, msg,
-                    details, outOfSyncURL);
+                    ((PortletResponseWrapper) response).getPortletResponse(),
+                    cap, msg, details, outOfSyncURL);
         }
 
         public String getRequestPathInfo(WrappedRequest request) {