From 3422f674a45b0a4bd48dda9e2856148c974b1f20 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 21 Apr 2011 12:38:42 +0000 Subject: [PATCH] #6871 Make it possible to provide a custom CommunicationManager for portlets svn changeset:18430/svn branch:6.6 --- .../server/AbstractApplicationPortlet.java | 35 ++++++++++++------- .../server/PortletApplicationContext2.java | 7 +++- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 6750b1faa8..8717a080b8 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -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); + } + } diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java index 65548b1933..69443958e5 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java +++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java @@ -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 -- 2.39.5