diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-01-19 14:48:57 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-01-19 14:48:57 +0000 |
commit | 2b3608fe37002c3e25807a30d73c13facf356530 (patch) | |
tree | 3dcb995ee49b9530510d1fe32ac9d1fb31b138bd /src/com/vaadin/terminal | |
parent | 6c0ff7452815dcc2efab394099ca36c3f26e68c9 (diff) | |
download | vaadin-framework-2b3608fe37002c3e25807a30d73c13facf356530.tar.gz vaadin-framework-2b3608fe37002c3e25807a30d73c13facf356530.zip |
opening the servlet implementation for customized communication ( e.g. jsonp, websockets)
* WebApplicationContext implementation can now be overridden in servlets via getApplicationContext method. Deprecated createCommunicationManager method as it is now obsolete (introduced earlier in 6.5 branch, dontpush is the only known user).
* opened getApplicationUrl for special implementations
svn changeset:16950/svn branch:6.5
Diffstat (limited to 'src/com/vaadin/terminal')
3 files changed, 39 insertions, 17 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 9379766130..bf3ba8f759 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -432,8 +432,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * Get or create a WebApplicationContext and an ApplicationManager * for the session */ - WebApplicationContext webApplicationContext = WebApplicationContext - .getApplicationContext(request.getSession()); + WebApplicationContext webApplicationContext = getApplicationContext(request + .getSession()); CommunicationManager applicationManager = webApplicationContext .getApplicationManager(application, this); @@ -934,8 +934,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements throws ServletException, MalformedURLException { Application newApplication = getNewApplication(request); - final WebApplicationContext context = WebApplicationContext - .getApplicationContext(request.getSession()); + final WebApplicationContext context = getApplicationContext(request + .getSession()); context.addApplication(newApplication); return newApplication; @@ -2008,7 +2008,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * if the application is denied access to the persistent data * store represented by the given URL. */ - URL getApplicationUrl(HttpServletRequest request) + protected URL getApplicationUrl(HttpServletRequest request) throws MalformedURLException { final URL reqURL = new URL( (request.isSecure() ? "https://" : "http://") @@ -2066,8 +2066,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements throw new SessionExpiredException(); } - WebApplicationContext context = WebApplicationContext - .getApplicationContext(session); + WebApplicationContext context = getApplicationContext(session); // Gets application list for the session. final Collection<Application> applications = context.getApplications(); @@ -2088,8 +2087,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } // Application has stopped, so remove it before creating a new // application - WebApplicationContext.getApplicationContext(session) - .removeApplication(sessionApplication); + getApplicationContext(session).removeApplication( + sessionApplication); break; } } @@ -2121,8 +2120,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements final HttpSession session = request.getSession(); if (session != null) { - WebApplicationContext.getApplicationContext(session) - .removeApplication(application); + getApplicationContext(session).removeApplication(application); } response.sendRedirect(response.encodeRedirectURL(logoutUrl)); @@ -2214,13 +2212,31 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements application.close(); if (session != null) { - WebApplicationContext context = WebApplicationContext - .getApplicationContext(session); + WebApplicationContext context = getApplicationContext(session); context.removeApplication(application); } } /** + * + * Gets the application context from an HttpSession. If no context is + * currently stored in a session a new context is created and stored in the + * session. + * + * @param session + * the HTTP session. + * @return the application context for HttpSession. + */ + protected WebApplicationContext getApplicationContext(HttpSession session) { + /* + * TODO the ApplicationContext.getApplicationContext() should be removed + * and logic moved here. Now overriding context type is possible, but + * the whole creation logic should be here. MT 1101 + */ + return WebApplicationContext.getApplicationContext(session); + } + + /** * Implementation of ParameterHandler.ErrorEvent interface. */ public class ParameterHandlerErrorImpl implements @@ -2307,12 +2323,18 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * Override this method if you need to use a specialized communicaiton * mananger implementation. * - * TODO figure out the right place for CM instantiation, must be - * overridieable + * @deprecated Instead of overriding this method, override + * {@link WebApplicationContext} implementation via + * {@link AbstractApplicationServlet#getApplicationContext(HttpSession)} + * method and in that customized implementation return your + * CommunicationManager in + * {@link WebApplicationContext#getApplicationManager(Application, AbstractApplicationServlet)} + * method. * * @param application * @return */ + @Deprecated public CommunicationManager createCommunicationManager( Application application) { return new CommunicationManager(application); diff --git a/src/com/vaadin/terminal/gwt/server/ApplicationRunnerServlet.java b/src/com/vaadin/terminal/gwt/server/ApplicationRunnerServlet.java index 5e660ab82c..10f0b94dda 100644 --- a/src/com/vaadin/terminal/gwt/server/ApplicationRunnerServlet.java +++ b/src/com/vaadin/terminal/gwt/server/ApplicationRunnerServlet.java @@ -48,7 +48,7 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { } @Override - URL getApplicationUrl(HttpServletRequest request) + protected URL getApplicationUrl(HttpServletRequest request) throws MalformedURLException { URL url = super.getApplicationUrl(request); diff --git a/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java index 5f8e59e056..86dbd910d5 100644 --- a/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java @@ -320,7 +320,7 @@ public class GAEApplicationServlet extends ApplicationServlet { } } // will create new context if the above did not - return WebApplicationContext.getApplicationContext(session); + return getApplicationContext(session); } |