]> source.dussan.org Git - vaadin-framework.git/commitdiff
Move PortletWrapper to AbstractApplicationPortlet
authorLeif Åstrand <leif@vaadin.com>
Tue, 8 Nov 2011 14:01:46 +0000 (16:01 +0200)
committerLeif Åstrand <leif@vaadin.com>
Tue, 8 Nov 2011 14:01:46 +0000 (16:01 +0200)
src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java

index d785d4c69950727d8120656868ac647508804ad1..c4b8e0f1f3d1357a849d296b13c31194f0497a51 100644 (file)
@@ -52,8 +52,11 @@ import com.liferay.portal.kernel.util.PropsUtil;
 import com.vaadin.Application;
 import com.vaadin.Application.SystemMessages;
 import com.vaadin.terminal.Terminal;
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.terminal.WrappedResponse;
 import com.vaadin.terminal.gwt.client.ApplicationConfiguration;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.server.AbstractCommunicationManager.Callback;
 import com.vaadin.ui.Root;
 
 /**
@@ -70,6 +73,37 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
     private static final Logger logger = Logger
             .getLogger(AbstractApplicationPortlet.class.getName());
 
+    private static class AbstractApplicationPortletWrapper implements Callback {
+
+        private final AbstractApplicationPortlet portlet;
+
+        public AbstractApplicationPortletWrapper(
+                AbstractApplicationPortlet portlet) {
+            this.portlet = portlet;
+        }
+
+        public void criticalNotification(WrappedRequest request,
+                WrappedResponse response, String cap, String msg,
+                String details, String outOfSyncURL) throws IOException {
+            portlet.criticalNotification(
+                    ((WrappedPortletRequest) request).getPortletRequest(),
+                    ((WrappedPortletResponse) response).getPortletResponse(),
+                    cap, msg, details, outOfSyncURL);
+        }
+
+        public String getRequestPathInfo(WrappedRequest request) {
+            return request.getRequestPathInfo();
+        }
+
+        public InputStream getThemeResourceAsStream(String themeName,
+                String resource) throws IOException {
+            return portlet.getPortletContext().getResourceAsStream(
+                    "/" + AbstractApplicationPortlet.THEME_DIRECTORY_PATH
+                            + themeName + "/" + resource);
+        }
+
+    }
+
     /**
      * This portlet parameter is used to add styles to the main element. E.g
      * "height:500px" generates a style="height:500px" to the main element.
@@ -325,6 +359,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
 
     protected void handleRequest(PortletRequest request,
             PortletResponse response) throws PortletException, IOException {
+        AbstractApplicationPortletWrapper portletWrapper = new AbstractApplicationPortletWrapper(
+                this);
         RequestType requestType = getRequestType(request);
 
         if (requestType == RequestType.UNKNOWN) {
@@ -411,7 +447,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
                             break;
                         default:
                             root = applicationManager.getApplicationRoot(
-                                    request, this, application, null);
+                                    request, portletWrapper, application, null);
                         }
                         // if window not found, not a problem - use null
                     }
@@ -451,7 +487,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
                     }
                     applicationManager.handleUidlRequest(
                             (ResourceRequest) request,
-                            (ResourceResponse) response, this, root);
+                            (ResourceResponse) response, portletWrapper, root);
                     return;
                 } else {
                     /*
index 96e371d74917b586af7123dd260b47fdfde22e4c..95f03c7b1a79798ea02433eb61ee0f9b42b2a83d 100644 (file)
@@ -4,7 +4,6 @@
 package com.vaadin.terminal.gwt.server;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -19,8 +18,6 @@ import com.vaadin.Application;
 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;
 
@@ -35,37 +32,6 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
 
     private transient ResourceResponse currentUidlResponse;
 
-    private static class AbstractApplicationPortletWrapper implements Callback {
-
-        private final AbstractApplicationPortlet portlet;
-
-        public AbstractApplicationPortletWrapper(
-                AbstractApplicationPortlet portlet) {
-            this.portlet = portlet;
-        }
-
-        public void criticalNotification(WrappedRequest request,
-                WrappedResponse response, String cap, String msg,
-                String details, String outOfSyncURL) throws IOException {
-            portlet.criticalNotification(
-                    ((WrappedPortletRequest) request).getPortletRequest(),
-                    ((WrappedPortletResponse) response).getPortletResponse(),
-                    cap, msg, details, outOfSyncURL);
-        }
-
-        public String getRequestPathInfo(WrappedRequest request) {
-            return request.getRequestPathInfo();
-        }
-
-        public InputStream getThemeResourceAsStream(String themeName,
-                String resource) throws IOException {
-            return portlet.getPortletContext().getResourceAsStream(
-                    "/" + AbstractApplicationPortlet.THEME_DIRECTORY_PATH
-                            + themeName + "/" + resource);
-        }
-
-    }
-
     public PortletCommunicationManager(Application application) {
         super(application);
     }
@@ -101,13 +67,11 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
     }
 
     public void handleUidlRequest(ResourceRequest request,
-            ResourceResponse response,
-            AbstractApplicationPortlet applicationPortlet, Root root)
+            ResourceResponse response, Callback callback, Root root)
             throws InvalidUIDLSecurityKeyException, IOException {
         currentUidlResponse = response;
         doHandleUidlRequest(new WrappedPortletRequest(request),
-                new WrappedPortletResponse(response),
-                new AbstractApplicationPortletWrapper(applicationPortlet), root);
+                new WrappedPortletResponse(response), callback, root);
         currentUidlResponse = null;
     }
 
@@ -128,13 +92,11 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
      *             if an exception has occurred that interferes with the
      *             servlet's normal operation.
      */
-    Root getApplicationRoot(PortletRequest request,
-            AbstractApplicationPortlet applicationPortlet,
+    Root getApplicationRoot(PortletRequest request, Callback callback,
             Application application, Root assumedRoot) {
 
         return doGetApplicationWindow(new WrappedPortletRequest(request),
-                new AbstractApplicationPortletWrapper(applicationPortlet),
-                application, assumedRoot);
+                callback, application, assumedRoot);
     }
 
     private Map<VariableOwner, Map<String, StreamVariable>> ownerToNameToStreamVariable;