]> source.dussan.org Git - vaadin-framework.git/commitdiff
Remove CombinedRequest and BrowserDetails (#8165) 71/71/2
authorLeif Åstrand <leif@vaadin.com>
Mon, 8 Oct 2012 14:07:25 +0000 (17:07 +0300)
committerLeif Åstrand <leif@vaadin.com>
Mon, 8 Oct 2012 14:07:25 +0000 (17:07 +0300)
* Primary use case for CombinedRequest (special path and parameters)
already elimiated by other changes
* BrowserDetails.getLocation is now available through Page
* BrowserDetails.getWindowName only used internally in one location
* VaadinServletRequest.cast and similar for portlets removed now that a
normal cast can always be used as there's no CombinedRequest to consider

Change-Id: I44f28722a12f86015b3c30e83768e4611b87479c

19 files changed:
server/src/com/vaadin/server/AbstractCommunicationManager.java
server/src/com/vaadin/server/CombinedRequest.java [deleted file]
server/src/com/vaadin/server/LegacyVaadinPortlet.java
server/src/com/vaadin/server/Page.java
server/src/com/vaadin/server/PortletCommunicationManager.java
server/src/com/vaadin/server/UnsupportedBrowserHandler.java
server/src/com/vaadin/server/VaadinPortlet.java
server/src/com/vaadin/server/VaadinPortletRequest.java
server/src/com/vaadin/server/VaadinPortletService.java
server/src/com/vaadin/server/VaadinRequest.java
server/src/com/vaadin/server/VaadinServlet.java
server/src/com/vaadin/server/VaadinServletRequest.java
server/src/com/vaadin/server/VaadinServletService.java
server/src/com/vaadin/ui/UI.java
uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java
uitest/src/com/vaadin/tests/application/RefreshStatePreserve.java
uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java
uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java
uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java

index 0a3b18b86bc85f569a2b9660abed0bef2db05f82..5852ff2a93821cb197a2184d0924e4cb91180e41 100644 (file)
@@ -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 (file)
index 5cb5b67..0000000
+++ /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();
-    }
-}
index 0c6f7afd9335ee3ae37af01b50c4a204709fdd96..f186971f7cfb13638a804dfe3111dabc8ac3f4ac 100644 (file)
@@ -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);
index ff0980d5fb5abc777b73c3e481685eebffed9924..510bb4734bd49f6963459775e46ac3fedbb51369 100644 (file)
@@ -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);
+            }
         }
     }
 
index 635202a0747052d235fdfc753ade97bef15c4d4d..8b1b14e568c3cc21e26841998a1e4dc39355df43 100644 (file)
@@ -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);
index e9c081387a9fb7dd751706a6d4b8296a893f7f48..cd3498fd578086a54ff895dc086cc5f265dc4884 100644 (file)
@@ -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 ("
index 95178ade17140a18e5321a680cdeb5debb3ccd80..db1425ba12bdb3019cce101d30c248a46e52f68b 100644 (file)
@@ -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);
         }
index 08e809eed276daeb373ba9d9a5bfbfc59e0b6440..f4ad0403214f4fdac95e03146b13653e77fa6bf8 100644 (file)
@@ -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;
 
@@ -148,28 +147,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();
index 12bf45f43ab3c07f80a735cbd9e65953c92d9973..bc51fdd2a55edf17e3be3ac5cc3d69a3fad0e47f 100644 (file)
@@ -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
index 650b5ad82b2047bcf4dc618b892c68ac4384a148..f5786c9b80abb65371edbef09249bd17a23611aa 100644 (file)
@@ -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
@@ -215,24 +178,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.
index 68fca7b46353eb22b29f823b7b793c51ef6c8e90..c4483b5f795f44150891604f6b3793f2b0bf06f9 100644 (file)
@@ -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);
         }
index 5a7e96763b06077040b5b91d40ba50a87197971c..5b4b87624405966c0b750c93273babb8c3a82deb 100644 (file)
@@ -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
index 9992b3698db0283b351bc673e771ec5b2d6aa1ac..faec2871668aa8c57c737943c2ca35457367b03c 100644 (file)
@@ -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
index 0954bbec13a003e0454b29c0c51e36e09c2ddce9..1ac4a6cba02496f7c31df83dac6783ecceb986d6 100644 (file)
@@ -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
index 0c2a1f965a0b3eb5c9aef38d7d153a99e0c8e327..37f74471d2dbc9db21a8dcb9cdaf8513d3c7f30b 100644 (file)
@@ -162,8 +162,7 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet {
             throw new ServiceException(
                     new InstantiationException(
                             "Failed to load application class: "
-                                    + getApplicationRunnerApplicationClassName(VaadinServletRequest
-                                            .cast(request))));
+                                    + getApplicationRunnerApplicationClassName((VaadinServletRequest) request)));
         }
     }
 
index 5e406a5c9866e70ec158c460ee0a0cddd896b888..c99e384f8139d72b1292308f02367a24ea2d01c6 100644 (file)
@@ -10,8 +10,8 @@ public class RefreshStatePreserve extends AbstractTestUI {
 
     @Override
     protected void setup(VaadinRequest request) {
-        addComponent(new Label("window.name: "
-                + request.getBrowserDetails().getWindowName()));
+        // Internal parameter sent by vaadinBootstrap.js,
+        addComponent(new Label("window.name: " + request.getParameter("wn")));
         addComponent(new Label("UI id: " + getUIId()));
     }
 
index e1fae91a3c9865be9cfa099505c8c5e6ef15f709..1064f2e7669a5e2abfd105ed04bdad91a3e26ff5 100644 (file)
@@ -1,6 +1,7 @@
 package com.vaadin.tests.components.ui;
 
 import com.vaadin.server.ExternalResource;
+import com.vaadin.server.Page;
 import com.vaadin.server.UIClassSelectionEvent;
 import com.vaadin.server.UICreateEvent;
 import com.vaadin.server.UIProviderEvent;
@@ -76,7 +77,7 @@ public class LazyInitUIs extends AbstractTestUIProvider {
         info += "<br />pathInfo: " + request.getRequestPathInfo();
         info += "<br />parameters: " + request.getParameterMap().keySet();
         info += "<br />uri fragment: "
-                + request.getBrowserDetails().getLocation().getFragment();
+                + Page.getCurrent().getLocation().getFragment();
         return new Label(info, ContentMode.HTML);
     }
 
index ad3a30d4ca1ce27e1e1ddbbf6f1487d288457477..737de108940143a14d7e6813441380e0a16d42d9 100644 (file)
@@ -67,7 +67,7 @@ class DefaultRoot extends UI {
 class TouchRoot extends UI {
     @Override
     protected void init(VaadinRequest request) {
-        WebBrowser webBrowser = request.getBrowserDetails().getWebBrowser();
+        WebBrowser webBrowser = getSession().getBrowser();
         String screenSize = "" + webBrowser.getScreenWidth() + "x"
                 + webBrowser.getScreenHeight();
         getContent().addComponent(
index db8b2616283dc84231a67497a0c80e3460277905..6d9890a21c91b9c5b6afa8c4611819f7e2af6afb 100644 (file)
@@ -36,7 +36,7 @@ public class UsingUriFragments extends UI {
     @Override
     protected void init(VaadinRequest request) {
         Label label = new Label("Hello, your fragment is "
-                + request.getBrowserDetails().getLocation().getFragment());
+                + getPage().getLocation().getFragment());
         getContent().addComponent(label);
 
         // React to fragment changes
@@ -48,7 +48,7 @@ public class UsingUriFragments extends UI {
         });
 
         // Handle the fragment received in the initial request
-        handleFragment(request.getBrowserDetails().getLocation().getFragment());
+        handleFragment(getPage().getLocation().getFragment());
 
         addComponent(new Button("Show and set fragment",
                 new Button.ClickListener() {