From 3d3bfbcfc7b380914cfc40009ec1ec2aac1a9453 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 16 Nov 2011 14:34:45 +0200 Subject: [PATCH] Simplify the way the Root is determined for a request --- .../server/AbstractApplicationPortlet.java | 3 +- .../server/AbstractApplicationServlet.java | 55 ++----------------- .../server/AbstractCommunicationManager.java | 8 +-- 3 files changed, 7 insertions(+), 59 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 9c6fe479d8..f07b5f14b9 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -452,8 +452,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet break; default: root = applicationManager.getApplicationRoot( - wrappedRequest, portletWrapper, - application, null); + wrappedRequest, application); } // if window not found, not a problem - use null } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 7a99c118df..0e6e9b82d9 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -520,7 +520,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } else if (requestType == RequestType.UIDL) { // Handles AJAX UIDL requests Root root = applicationManager.getApplicationRoot( - wrappedRequest, servletWrapper, application, null); + wrappedRequest, application); applicationManager.handleUidlRequest(wrappedRequest, wrappedResponse, servletWrapper, root); return; @@ -540,8 +540,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements // TODO Should return 404 error here and not do anything more // Finds the root within the application - Root root = getApplicationRoot(wrappedRequest, applicationManager, - servletWrapper, application); + Root root = applicationManager.getApplicationRoot(wrappedRequest, + application); if (root == null) { throw new ServletException(ERROR_NO_WINDOW_FOUND); } @@ -1648,7 +1648,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements appId = appId + "-" + hashCode; writeAjaxPageHtmlVaadinScripts(themeName, application, page, appUrl, - themeUri, appId, request, application.getRootId(root)); + themeUri, appId, request, root.getRootId()); /*- Add classnames; * .v-app @@ -2155,53 +2155,6 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements response.sendRedirect(response.encodeRedirectURL(logoutUrl)); } - /** - * Gets the existing application or create a new one. Get a root within an - * application based on the requested URI. - * - * @param request - * the HTTP Request. - * @param application - * the Application to query for root. - * @param servletWrapper - * @return Root matching the given URI or null if not found. - * @throws ServletException - * if an exception has occurred that interferes with the - * servlet's normal operation. - */ - protected Root getApplicationRoot(WrappedRequest request, - CommunicationManager applicationManager, Callback servletWrapper, - Application application) throws ServletException { - // - // // Finds the window where the request is handled - Root assumedRoot = null; - // String path = getRequestPathInfo(request); - // - // // Main window as the URI is empty - // if (!(path == null || path.length() == 0 || path.equals("/"))) { - // if (path.startsWith("/APP/")) { - // // Use main window for application resources - // return application.getMainWindow(); - // } - // String windowName = null; - // if (path.charAt(0) == '/') { - // path = path.substring(1); - // } - // final int index = path.indexOf('/'); - // if (index < 0) { - // windowName = path; - // path = ""; - // } else { - // windowName = path.substring(0, index); - // } - // assumedWindow = application.getWindow(windowName); - // - // } - // - return applicationManager.getApplicationRoot(request, servletWrapper, - application, assumedRoot); - } - /** * Returns the path info; note that this _can_ be different than * request.getPathInfo(). Examples where this might be useful: diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 558922f2df..33e9994233 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -1633,14 +1633,10 @@ public abstract class AbstractCommunicationManager implements * the HTTP Request. * @param application * the Application to query for window. - * @param assumedRoot - * if the window has been already resolved once, this parameter - * must contain the window. - * @param callback * @return Window matching the given URI or null if not found. */ - public Root getApplicationRoot(WrappedRequest request, Callback callback, - Application application, Root assumedRoot) { + public Root getApplicationRoot(WrappedRequest request, + Application application) { String rootIdString = request .getParameter(ApplicationConnection.ROOT_ID_PARAMETER); Root root = null; -- 2.39.5