diff options
author | Henri Sara <hesara@vaadin.com> | 2012-10-08 14:17:05 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-10-08 14:17:05 +0000 |
commit | d6814d6406898a6670ad5522bc8b36e578af5ef0 (patch) | |
tree | b9455079ebb0d12ad67e864ccc1b91d37f774191 /server | |
parent | d43d15454d7cbc70f0a03d4e6666c747d7a4f657 (diff) | |
parent | 38bfea7cfa409dfe0864a5f42fb528007499999d (diff) | |
download | vaadin-framework-d6814d6406898a6670ad5522bc8b36e578af5ef0.tar.gz vaadin-framework-d6814d6406898a6670ad5522bc8b36e578af5ef0.zip |
Merge "Remove CombinedRequest and BrowserDetails (#8165)"
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/AbstractCommunicationManager.java | 20 | ||||
-rw-r--r-- | server/src/com/vaadin/server/CombinedRequest.java | 174 | ||||
-rw-r--r-- | server/src/com/vaadin/server/LegacyVaadinPortlet.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/server/Page.java | 13 | ||||
-rw-r--r-- | server/src/com/vaadin/server/PortletCommunicationManager.java | 10 | ||||
-rw-r--r-- | server/src/com/vaadin/server/UnsupportedBrowserHandler.java | 22 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinPortlet.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinPortletRequest.java | 42 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinPortletService.java | 34 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinRequest.java | 55 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinServlet.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinServletRequest.java | 42 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinServletService.java | 22 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/UI.java | 4 |
14 files changed, 57 insertions, 387 deletions
diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index 0a3b18b86b..5852ff2a93 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -68,7 +68,6 @@ import com.vaadin.server.StreamVariable.StreamingEndEvent; import com.vaadin.server.StreamVariable.StreamingErrorEvent; import com.vaadin.server.Terminal.ErrorEvent; import com.vaadin.server.Terminal.ErrorListener; -import com.vaadin.server.VaadinRequest.BrowserDetails; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Connector; import com.vaadin.shared.JavaScriptConnectorState; @@ -86,7 +85,6 @@ import com.vaadin.ui.HasComponents; import com.vaadin.ui.UI; import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Window; -import com.vaadin.util.CurrentInstance; /** * This is a common base class for the server-side implementations of the @@ -2430,16 +2428,13 @@ public abstract class AbstractCommunicationManager implements Serializable { try { assert UI.getCurrent() == null; - CombinedRequest combinedRequest = new CombinedRequest(request); - CurrentInstance.set(VaadinRequest.class, combinedRequest); - response.setContentType("application/json; charset=UTF-8"); - UI uI = getBrowserDetailsUI(combinedRequest); + UI uI = getBrowserDetailsUI(request); JSONObject params = new JSONObject(); params.put(UIConstants.UI_ID_PARAMETER, uI.getUIId()); - String initialUIDL = getInitialUIDL(combinedRequest, uI); + String initialUIDL = getInitialUIDL(request, uI); params.put("uidl", initialUIDL); // NOTE! GateIn requires, for some weird reason, getOutputStream @@ -2498,17 +2493,15 @@ public abstract class AbstractCommunicationManager implements Serializable { } // Check for an existing UI based on window.name - BrowserDetails browserDetails = request.getBrowserDetails(); - boolean hasBrowserDetails = browserDetails != null - && browserDetails.getLocation() != null; + + // Special parameter sent by vaadinBootstrap.js + String windowName = request.getParameter("wn"); Map<String, Integer> retainOnRefreshUIs = session .getPreserveOnRefreshUIs(); - if (hasBrowserDetails && !retainOnRefreshUIs.isEmpty()) { + if (windowName != null && !retainOnRefreshUIs.isEmpty()) { // Check for a known UI - @SuppressWarnings("null") - String windowName = browserDetails.getWindowName(); Integer retainedUIId = retainOnRefreshUIs.get(windowName); if (retainedUIId != null) { @@ -2550,7 +2543,6 @@ public abstract class AbstractCommunicationManager implements Serializable { // Remember if it should be remembered if (vaadinService.preserveUIOnRefresh(provider, event)) { // Remember this UI - String windowName = request.getBrowserDetails().getWindowName(); if (windowName == null) { getLogger().warning( "There is no window.name available for UI " + uiClass diff --git a/server/src/com/vaadin/server/CombinedRequest.java b/server/src/com/vaadin/server/CombinedRequest.java deleted file mode 100644 index 5cb5b674b6..0000000000 --- a/server/src/com/vaadin/server/CombinedRequest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.server; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Locale; -import java.util.Map; - -import org.json.JSONException; - -/** - * A {@link VaadinRequest} with path and parameters from one request and - * {@link VaadinRequest.BrowserDetails} extracted from another request. - * - * This class is intended to be used for a two request initialization where the - * first request fetches the actual application page and the second request - * contains information extracted from the browser using javascript. - * - */ -public class CombinedRequest implements VaadinRequest { - - private final VaadinRequest secondRequest; - - /** - * Creates a new combined request based on the second request and some - * details from the first request. - * - * @param secondRequest - * the second request which will be used as the foundation of the - * combined request - * @throws JSONException - * if the initialParams parameter can not be decoded - */ - public CombinedRequest(VaadinRequest secondRequest) throws JSONException { - this.secondRequest = secondRequest; - } - - @Override - public String getParameter(String parameter) { - return secondRequest.getParameter(parameter); - } - - @Override - public Map<String, String[]> getParameterMap() { - return secondRequest.getParameterMap(); - } - - @Override - public int getContentLength() { - return secondRequest.getContentLength(); - } - - @Override - public InputStream getInputStream() throws IOException { - return secondRequest.getInputStream(); - } - - @Override - public Object getAttribute(String name) { - return secondRequest.getAttribute(name); - } - - @Override - public void setAttribute(String name, Object value) { - secondRequest.setAttribute(name, value); - } - - @Override - public String getRequestPathInfo() { - return secondRequest.getRequestPathInfo(); - } - - @Override - public WrappedSession getWrappedSession() { - return getWrappedSession(true); - } - - @Override - public WrappedSession getWrappedSession(boolean allowSessionCreation) { - return secondRequest.getWrappedSession(allowSessionCreation); - } - - @Override - public String getContentType() { - return secondRequest.getContentType(); - } - - @Override - public BrowserDetails getBrowserDetails() { - return new BrowserDetails() { - @Override - public URI getLocation() { - String location = secondRequest.getParameter("loc"); - if (location == null) { - return null; - } else { - try { - return new URI(location); - } catch (URISyntaxException e) { - throw new RuntimeException( - "Invalid location URI received from client", e); - } - } - } - - @Override - public String getWindowName() { - return secondRequest.getParameter("wn"); - } - - @Override - public WebBrowser getWebBrowser() { - return VaadinServiceSession.getCurrent().getBrowser(); - } - }; - } - - /** - * Gets the original second request. This can be used e.g. if a request - * parameter from the second request is required. - * - * @return the original second Vaadin request - */ - public VaadinRequest getSecondRequest() { - return secondRequest; - } - - @Override - public Locale getLocale() { - return secondRequest.getLocale(); - } - - @Override - public String getRemoteAddr() { - return secondRequest.getRemoteAddr(); - } - - @Override - public boolean isSecure() { - return secondRequest.isSecure(); - } - - @Override - public String getHeader(String name) { - return secondRequest.getHeader(name); - } - - @Override - public VaadinService getService() { - return secondRequest.getService(); - } - - @Override - public String getContextPath() { - return secondRequest.getContextPath(); - } -} diff --git a/server/src/com/vaadin/server/LegacyVaadinPortlet.java b/server/src/com/vaadin/server/LegacyVaadinPortlet.java index 0c6f7afd93..f186971f7c 100644 --- a/server/src/com/vaadin/server/LegacyVaadinPortlet.java +++ b/server/src/com/vaadin/server/LegacyVaadinPortlet.java @@ -54,7 +54,7 @@ public class LegacyVaadinPortlet extends VaadinPortlet { throws ServiceException { try { onVaadinSessionStarted( - VaadinPortletRequest.cast(event.getRequest()), + (VaadinPortletRequest) event.getRequest(), (VaadinPortletSession) event.getSession()); } catch (PortletException e) { throw new ServiceException(e); diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index ff0980d5fb..510bb4734b 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -26,7 +26,6 @@ import java.util.LinkedList; import java.util.List; import com.vaadin.event.EventRouter; -import com.vaadin.server.VaadinRequest.BrowserDetails; import com.vaadin.shared.ui.BorderStyle; import com.vaadin.shared.ui.ui.PageClientRpc; import com.vaadin.shared.ui.ui.UIConstants; @@ -433,9 +432,15 @@ public class Page implements Serializable { } public void init(VaadinRequest request) { - BrowserDetails browserDetails = request.getBrowserDetails(); - if (browserDetails != null) { - location = browserDetails.getLocation(); + // Extract special parameter sent by vaadinBootstrap.js + String loc = request.getParameter("loc"); + if (loc != null) { + try { + location = new URI(loc); + } catch (URISyntaxException e) { + throw new RuntimeException( + "Invalid location URI received from client", e); + } } } diff --git a/server/src/com/vaadin/server/PortletCommunicationManager.java b/server/src/com/vaadin/server/PortletCommunicationManager.java index 635202a074..8b1b14e568 100644 --- a/server/src/com/vaadin/server/PortletCommunicationManager.java +++ b/server/src/com/vaadin/server/PortletCommunicationManager.java @@ -55,8 +55,8 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { public boolean handleRequest(VaadinServiceSession session, VaadinRequest request, VaadinResponse response) throws IOException { - PortletRequest portletRequest = VaadinPortletRequest.cast( - request).getPortletRequest(); + PortletRequest portletRequest = ((VaadinPortletRequest) request) + .getPortletRequest(); if (portletRequest instanceof RenderRequest) { return super.handleRequest(session, request, response); } else { @@ -86,9 +86,9 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { throws JSONException, IOException { // fixed base theme to use - all portal pages with Vaadin // applications will load this exactly once - String portalTheme = VaadinPortletRequest.cast( - context.getRequest()).getPortalProperty( - VaadinPortlet.PORTAL_PARAMETER_VAADIN_THEME); + String portalTheme = ((VaadinPortletRequest) context + .getRequest()) + .getPortalProperty(VaadinPortlet.PORTAL_PARAMETER_VAADIN_THEME); if (portalTheme != null && !portalTheme.equals(context.getThemeName())) { String portalThemeUri = getThemeUri(context, portalTheme); diff --git a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java index e9c081387a..cd3498fd57 100644 --- a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java +++ b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java @@ -37,17 +37,15 @@ public class UnsupportedBrowserHandler implements RequestHandler { public boolean handleRequest(VaadinServiceSession session, VaadinRequest request, VaadinResponse response) throws IOException { - if (request.getBrowserDetails() != null) { - // Check if the browser is supported - // If Chrome Frame is available we'll assume it's ok - WebBrowser b = request.getBrowserDetails().getWebBrowser(); - if (b.isTooOldToFunctionProperly() && !b.isChromeFrameCapable()) { - // bypass if cookie set - String c = request.getHeader("Cookie"); - if (c == null || !c.contains(FORCE_LOAD_COOKIE)) { - writeBrowserTooOldPage(request, response); - return true; // request handled - } + // Check if the browser is supported + // If Chrome Frame is available we'll assume it's ok + WebBrowser b = session.getBrowser(); + if (b.isTooOldToFunctionProperly() && !b.isChromeFrameCapable()) { + // bypass if cookie set + String c = request.getHeader("Cookie"); + if (c == null || !c.contains(FORCE_LOAD_COOKIE)) { + writeBrowserTooOldPage(request, response); + return true; // request handled } } @@ -64,7 +62,7 @@ public class UnsupportedBrowserHandler implements RequestHandler { protected void writeBrowserTooOldPage(VaadinRequest request, VaadinResponse response) throws IOException { Writer page = response.getWriter(); - WebBrowser b = request.getBrowserDetails().getWebBrowser(); + WebBrowser b = VaadinServiceSession.getCurrent().getBrowser(); page.write("<html><body><h1>I'm sorry, but your browser is not supported</h1>" + "<p>The version (" diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index 95178ade17..db1425ba12 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -184,7 +184,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { public void criticalNotification(VaadinRequest request, VaadinResponse response, String cap, String msg, String details, String outOfSyncURL) throws IOException { - portlet.criticalNotification(VaadinPortletRequest.cast(request), + portlet.criticalNotification((VaadinPortletRequest) request, (VaadinPortletResponse) response, cap, msg, details, outOfSyncURL); } diff --git a/server/src/com/vaadin/server/VaadinPortletRequest.java b/server/src/com/vaadin/server/VaadinPortletRequest.java index 08e809eed2..f4ad040321 100644 --- a/server/src/com/vaadin/server/VaadinPortletRequest.java +++ b/server/src/com/vaadin/server/VaadinPortletRequest.java @@ -18,7 +18,6 @@ package com.vaadin.server; import java.io.IOException; import java.io.InputStream; -import java.net.URI; import java.util.Locale; import java.util.Map; @@ -149,28 +148,6 @@ public class VaadinPortletRequest implements VaadinRequest { } @Override - public BrowserDetails getBrowserDetails() { - return new BrowserDetails() { - @Override - public URI getLocation() { - return null; - } - - @Override - public String getWindowName() { - return null; - } - - @Override - public WebBrowser getWebBrowser() { - VaadinPortletSession context = (VaadinPortletSession) VaadinServiceSession - .getCurrent(); - return context.getBrowser(); - } - }; - } - - @Override public Locale getLocale() { return request.getLocale(); } @@ -207,25 +184,6 @@ public class VaadinPortletRequest implements VaadinRequest { return vaadinService; } - /** - * Helper method to get a {@link VaadinPortletRequest} from a - * {@link VaadinRequest}. Aside from casting, this method also takes care of - * situations where there's another level of wrapping. - * - * @param request - * a Vaadin request - * @return a Vaadin portlet request - * @throws ClassCastException - * if the Vaadin request doesn't wrap a portlet request - */ - public static VaadinPortletRequest cast(VaadinRequest request) { - if (request instanceof CombinedRequest) { - CombinedRequest combinedRequest = (CombinedRequest) request; - request = combinedRequest.getSecondRequest(); - } - return (VaadinPortletRequest) request; - } - @Override public String getContextPath() { return request.getContextPath(); diff --git a/server/src/com/vaadin/server/VaadinPortletService.java b/server/src/com/vaadin/server/VaadinPortletService.java index 12bf45f43a..bc51fdd2a5 100644 --- a/server/src/com/vaadin/server/VaadinPortletService.java +++ b/server/src/com/vaadin/server/VaadinPortletService.java @@ -40,6 +40,12 @@ public class VaadinPortletService extends VaadinService { return portlet; } + private static String getPortalProperty(VaadinRequest request, + String portalParameterVaadinWidgetset) { + return ((VaadinPortletRequest) request) + .getPortalProperty(portalParameterVaadinWidgetset); + } + @Override public String getConfiguredWidgetset(VaadinRequest request) { @@ -50,7 +56,7 @@ public class VaadinPortletService extends VaadinService { if (widgetset == null) { // If no widgetset defined for the application, check the // portal property - widgetset = VaadinPortletRequest.cast(request).getPortalProperty( + widgetset = getPortalProperty(request, VaadinPortlet.PORTAL_PARAMETER_VAADIN_WIDGETSET); if ("com.vaadin.portal.gwt.PortalDefaultWidgetSet" .equals(widgetset)) { @@ -73,8 +79,8 @@ public class VaadinPortletService extends VaadinService { public String getConfiguredTheme(VaadinRequest request) { // is the default theme defined by the portal? - String themeName = VaadinPortletRequest.cast(request) - .getPortalProperty(Constants.PORTAL_PARAMETER_VAADIN_THEME); + String themeName = getPortalProperty(request, + Constants.PORTAL_PARAMETER_VAADIN_THEME); if (themeName == null) { // no, using the default theme defined by Vaadin @@ -91,9 +97,8 @@ public class VaadinPortletService extends VaadinService { @Override public String getStaticFileLocation(VaadinRequest request) { - String staticFileLocation = VaadinPortletRequest.cast(request) - .getPortalProperty( - Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH); + String staticFileLocation = getPortalProperty(request, + Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH); if (staticFileLocation != null) { // remove trailing slash if any while (staticFileLocation.endsWith(".")) { @@ -169,8 +174,7 @@ public class VaadinPortletService extends VaadinService { RequestType type = (RequestType) request.getAttribute(RequestType.class .getName()); if (type == null) { - type = getPortlet().getRequestType( - VaadinPortletRequest.cast(request)); + type = getPortlet().getRequestType((VaadinPortletRequest) request); request.setAttribute(RequestType.class.getName(), type); } return type; @@ -184,15 +188,9 @@ public class VaadinPortletService extends VaadinService { public static PortletRequest getCurrentPortletRequest() { VaadinRequest currentRequest = VaadinService.getCurrentRequest(); - try { - VaadinPortletRequest request = VaadinPortletRequest - .cast(currentRequest); - if (request != null) { - return request.getPortletRequest(); - } else { - return null; - } - } catch (ClassCastException e) { + if (currentRequest instanceof VaadinPortletRequest) { + return ((VaadinPortletRequest) currentRequest).getPortletRequest(); + } else { return null; } } @@ -223,7 +221,7 @@ public class VaadinPortletService extends VaadinService { @Override public String getMainDivId(VaadinServiceSession session, VaadinRequest request, Class<? extends UI> uiClass) { - PortletRequest portletRequest = VaadinPortletRequest.cast(request) + PortletRequest portletRequest = ((VaadinPortletRequest) request) .getPortletRequest(); /* * We need to generate a unique ID because some portals already create a diff --git a/server/src/com/vaadin/server/VaadinRequest.java b/server/src/com/vaadin/server/VaadinRequest.java index 650b5ad82b..f5786c9b80 100644 --- a/server/src/com/vaadin/server/VaadinRequest.java +++ b/server/src/com/vaadin/server/VaadinRequest.java @@ -19,7 +19,6 @@ package com.vaadin.server; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; -import java.net.URI; import java.util.Locale; import java.util.Map; @@ -27,8 +26,6 @@ import javax.portlet.PortletRequest; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; -import com.vaadin.ui.UI; - /** * A generic request to the server, wrapping a more specific request type, e.g. * HttpServletReqest or PortletRequest. @@ -37,40 +34,6 @@ import com.vaadin.ui.UI; * @since 7.0.0 */ public interface VaadinRequest extends Serializable { - - /** - * Detailed information extracted from the browser. - * - * @see VaadinRequest#getBrowserDetails() - * @deprecated might be refactored or removed before 7.0.0 - */ - @Deprecated - public interface BrowserDetails extends Serializable { - /** - * Gets the URI in the browser address bar, including the fragment - * (Javascript window.location) - * - * @return the browser location URI - */ - public URI getLocation(); - - /** - * Gets the value of window.name from the browser. This can be used to - * keep track of the specific window between browser reloads. - * - * @return the string value of window.name in the browser - */ - public String getWindowName(); - - /** - * Gets a reference to the {@link WebBrowser} object containing - * additional information, e.g. screen size and the time zone offset. - * - * @return the web browser object - */ - public WebBrowser getWebBrowser(); - } - /** * Gets the named request parameter This is typically a HTTP GET or POST * parameter, though other request types might have other ways of @@ -216,24 +179,6 @@ public interface VaadinRequest extends Serializable { public String getContentType(); /** - * Gets detailed information about the browser from which the request - * originated. This consists of information that is not available from - * normal HTTP requests, but requires additional information to be extracted - * for instance using javascript in the browser. - * - * This information is only guaranteed to be available in some special - * cases, for instance in {@link UI#init(VaadinRequest)}. - * - * @return the browser details, or <code>null</code> if details are not - * available - * - * @see BrowserDetails - * @deprecated might be refactored or removed before 7.0.0 - */ - @Deprecated - public BrowserDetails getBrowserDetails(); - - /** * Gets locale information from the query, e.g. using the Accept-Language * header. * diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 68fca7b463..c4483b5f79 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -63,7 +63,7 @@ public class VaadinServlet extends HttpServlet implements Constants { public void criticalNotification(VaadinRequest request, VaadinResponse response, String cap, String msg, String details, String outOfSyncURL) throws IOException { - servlet.criticalNotification(VaadinServletRequest.cast(request), + servlet.criticalNotification((VaadinServletRequest) request, ((VaadinServletResponse) response), cap, msg, details, outOfSyncURL); } diff --git a/server/src/com/vaadin/server/VaadinServletRequest.java b/server/src/com/vaadin/server/VaadinServletRequest.java index 5a7e96763b..5b4b876244 100644 --- a/server/src/com/vaadin/server/VaadinServletRequest.java +++ b/server/src/com/vaadin/server/VaadinServletRequest.java @@ -16,8 +16,6 @@ package com.vaadin.server; -import java.net.URI; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpSession; @@ -83,44 +81,4 @@ public class VaadinServletRequest extends HttpServletRequestWrapper implements public VaadinServletService getService() { return vaadinService; } - - @Override - public BrowserDetails getBrowserDetails() { - return new BrowserDetails() { - @Override - public URI getLocation() { - return null; - } - - @Override - public String getWindowName() { - return null; - } - - @Override - public WebBrowser getWebBrowser() { - return VaadinServiceSession.getCurrent().getBrowser(); - } - }; - } - - /** - * Helper method to get a {@link VaadinServletRequest} from a - * {@link VaadinRequest}. Aside from casting, this method also takes care of - * situations where there's another level of wrapping. - * - * @param request - * a Vaadin request - * @return a Vaadin http servlet request - * @throws ClassCastException - * if the Vaadin request doesn't wrap a http servlet request - */ - public static VaadinServletRequest cast(VaadinRequest request) { - if (request instanceof CombinedRequest) { - CombinedRequest combinedRequest = (CombinedRequest) request; - request = combinedRequest.getSecondRequest(); - } - return (VaadinServletRequest) request; - } - }
\ No newline at end of file diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java index 9992b3698d..faec287166 100644 --- a/server/src/com/vaadin/server/VaadinServletService.java +++ b/server/src/com/vaadin/server/VaadinServletService.java @@ -40,7 +40,7 @@ public class VaadinServletService extends VaadinService { @Override public String getStaticFileLocation(VaadinRequest request) { - HttpServletRequest servletRequest = VaadinServletRequest.cast(request); + VaadinServletRequest servletRequest = (VaadinServletRequest) request; String staticFileLocation; // if property is defined in configurations, use that staticFileLocation = getDeploymentConfiguration() @@ -146,8 +146,7 @@ public class VaadinServletService extends VaadinService { RequestType type = (RequestType) request.getAttribute(RequestType.class .getName()); if (type == null) { - type = getServlet().getRequestType( - VaadinServletRequest.cast(request)); + type = getServlet().getRequestType((VaadinServletRequest) request); request.setAttribute(RequestType.class.getName(), type); } return type; @@ -156,8 +155,7 @@ public class VaadinServletService extends VaadinService { @Override protected URL getApplicationUrl(VaadinRequest request) throws MalformedURLException { - return getServlet().getApplicationUrl( - VaadinServletRequest.cast(request)); + return getServlet().getApplicationUrl((VaadinServletRequest) request); } @Override @@ -168,15 +166,9 @@ public class VaadinServletService extends VaadinService { public static HttpServletRequest getCurrentServletRequest() { VaadinRequest currentRequest = VaadinService.getCurrentRequest(); - try { - VaadinServletRequest request = VaadinServletRequest - .cast(currentRequest); - if (request != null) { - return request.getHttpServletRequest(); - } else { - return null; - } - } catch (ClassCastException e) { + if (currentRequest instanceof VaadinServletRequest) { + return (VaadinServletRequest) currentRequest; + } else { return null; } } @@ -196,7 +188,7 @@ public class VaadinServletService extends VaadinService { String appId = null; try { URL appUrl = getServlet().getApplicationUrl( - VaadinServletRequest.cast(request)); + (VaadinServletRequest) request); appId = appUrl.getPath(); } catch (MalformedURLException e) { // Just ignore problem here diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 0954bbec13..1ac4a6cba0 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -43,7 +43,6 @@ import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; import com.vaadin.server.UIProvider; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinRequest.BrowserDetails; import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinServiceSession; import com.vaadin.server.VaadinServlet; @@ -1003,8 +1002,7 @@ public abstract class UI extends AbstractComponentContainer implements * state of the UI is not properly set up when the constructor is invoked. * <p> * The {@link VaadinRequest} can be used to get information about the - * request that caused this UI to be created. {@link BrowserDetails} will be - * available in the request. + * request that caused this UI to be created. * </p> * * @param request |