]> source.dussan.org Git - vaadin-framework.git/commitdiff
#6871 Make it possible to provide a custom CommunicationManager for portlets
authorArtur Signell <artur.signell@itmill.com>
Thu, 21 Apr 2011 12:38:42 +0000 (12:38 +0000)
committerArtur Signell <artur.signell@itmill.com>
Thu, 21 Apr 2011 12:38:42 +0000 (12:38 +0000)
svn changeset:18430/svn branch:6.6

src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java

index 6750b1faa8cd9ec3b34f147fc8af5c66884e4164..8717a080b83ae9e373d4f1c639380e99f7fe3910 100644 (file)
@@ -349,8 +349,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
                  * Get or create an application context and an application
                  * manager for the session
                  */
-                PortletApplicationContext2 applicationContext = PortletApplicationContext2
-                        .getApplicationContext(request.getPortletSession());
+                PortletApplicationContext2 applicationContext = getApplicationContext(request
+                        .getPortletSession());
                 applicationContext.setResponse(response);
                 applicationContext.setPortletConfig(getPortletConfig());
 
@@ -740,8 +740,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
             throws IOException {
         final PortletSession session = request.getPortletSession();
         if (session != null) {
-            PortletApplicationContext2.getApplicationContext(session)
-                    .removeApplication(application);
+            getApplicationContext(session).removeApplication(application);
         }
         // Do not send any redirects when running inside a portlet.
     }
@@ -796,8 +795,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
 
         application.close();
         if (session != null) {
-            PortletApplicationContext2 context = PortletApplicationContext2
-                    .getApplicationContext(session);
+            PortletApplicationContext2 context = getApplicationContext(session);
             context.removeApplication(application);
         }
     }
@@ -805,8 +803,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
     private Application createApplication(PortletRequest request)
             throws PortletException, MalformedURLException {
         Application newApplication = getNewApplication(request);
-        final PortletApplicationContext2 context = PortletApplicationContext2
-                .getApplicationContext(request.getPortletSession());
+        final PortletApplicationContext2 context = getApplicationContext(request
+                .getPortletSession());
         context.addApplication(newApplication, request.getWindowID());
         return newApplication;
     }
@@ -822,8 +820,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
             throw new SessionExpiredException();
         }
 
-        PortletApplicationContext2 context = PortletApplicationContext2
-                .getApplicationContext(session);
+        PortletApplicationContext2 context = getApplicationContext(session);
         Application application = context.getApplicationForWindowId(request
                 .getWindowID());
         if (application == null) {
@@ -833,8 +830,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
             return application;
         }
         // application found but not running
-        PortletApplicationContext2.getApplicationContext(session)
-                .removeApplication(application);
+        context.removeApplication(application);
 
         return null;
     }
@@ -1578,4 +1574,19 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
         return null;
     }
 
+    /**
+     * 
+     * Gets the application context for a PortletSession. If no context is
+     * currently stored in a session a new context is created and stored in the
+     * session.
+     * 
+     * @param portletSession
+     *            the portlet session.
+     * @return the application context for the session.
+     */
+    protected PortletApplicationContext2 getApplicationContext(
+            PortletSession portletSession) {
+        return PortletApplicationContext2.getApplicationContext(portletSession);
+    }
+
 }
index 65548b19339696de0e1fef806263898f9257d613..69443958e5a14fd008441e6397de8e95e57aff70 100644 (file)
@@ -94,12 +94,17 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext {
 
         if (mgr == null) {
             // Creates a new manager
-            mgr = new PortletCommunicationManager(application);
+            mgr = createPortletCommunicationManager(application);
             applicationToAjaxAppMgrMap.put(application, mgr);
         }
         return mgr;
     }
 
+    protected PortletCommunicationManager createPortletCommunicationManager(
+            Application application) {
+        return new PortletCommunicationManager(application);
+    }
+
     public static PortletApplicationContext2 getApplicationContext(
             PortletSession session) {
         PortletApplicationContext2 cx = (PortletApplicationContext2) session