]> source.dussan.org Git - vaadin-framework.git/commitdiff
Change the default to a two request bootstrap
authorLeif Åstrand <leif@vaadin.com>
Thu, 22 Dec 2011 09:23:20 +0000 (11:23 +0200)
committerLeif Åstrand <leif@vaadin.com>
Thu, 22 Dec 2011 09:23:29 +0000 (11:23 +0200)
Add @EagerInit annotation to indicate that that no browser details are
required, enabling a one request bootstrap.

src/com/vaadin/Application.java
src/com/vaadin/annotations/EagerInit.java [new file with mode: 0644]
src/com/vaadin/annotations/RootInitRequiresBrowserDetails.java [deleted file]
src/com/vaadin/terminal/WrappedRequest.java
src/com/vaadin/ui/Root.java
tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java
tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java

index 700f657937c809470df82c70237fdc81718064ae..bc2575a5fef44e9e803b62febcaa1a3344db1c85 100644 (file)
@@ -29,7 +29,7 @@ import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
+import com.vaadin.annotations.EagerInit;
 import com.vaadin.annotations.Theme;
 import com.vaadin.annotations.Widgetset;
 import com.vaadin.data.util.converter.Converter;
@@ -2268,8 +2268,8 @@ public class Application implements Terminal.ErrorListener, Serializable {
 
             if (!initedRoots.contains(rootId)) {
                 boolean initRequiresBrowserDetails = preserveRoot
-                        || root.getClass().isAnnotationPresent(
-                                RootInitRequiresBrowserDetails.class);
+                        || !root.getClass()
+                                .isAnnotationPresent(EagerInit.class);
                 if (initRequiresBrowserDetails && browserDetails == null) {
                     pendingRoots.put(rootId, new PendingRootRequest(request));
                 } else {
diff --git a/src/com/vaadin/annotations/EagerInit.java b/src/com/vaadin/annotations/EagerInit.java
new file mode 100644 (file)
index 0000000..0e9fbdb
--- /dev/null
@@ -0,0 +1,27 @@
+package com.vaadin.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.ui.Root;
+
+/**
+ * Indicates that the init method in a Root class can be called before full
+ * browser details ({@link WrappedRequest#getBrowserDetails()}) are available.
+ * This will make the UI appear more quickly, as ensuring the availability of
+ * this information typically requires an additional round trip to the client.
+ * 
+ * @see Root#init(com.vaadin.terminal.WrappedRequest)
+ * @see WrappedRequest#getBrowserDetails()
+ * 
+ * @since 7.0
+ * 
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface EagerInit {
+    // No values
+}
diff --git a/src/com/vaadin/annotations/RootInitRequiresBrowserDetails.java b/src/com/vaadin/annotations/RootInitRequiresBrowserDetails.java
deleted file mode 100644 (file)
index bd04d2e..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import com.vaadin.terminal.WrappedRequest;
-import com.vaadin.ui.Root;
-
-/**
- * Indicates that the init method in a Root class should not be called until
- * full browser details ({@link WrappedRequest#getBrowserDetails()}) are
- * available. Ensuring the availability of this information will typically
- * requires an additional round trip to the client, which will cause the
- * application startup to progress more slowly.
- * 
- * @see Root#init(com.vaadin.terminal.WrappedRequest)
- * @see WrappedRequest#getBrowserDetails()
- * 
- * @since 7.0
- * 
- */
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface RootInitRequiresBrowserDetails {
-    // No methods
-}
index 235a0513c731653095c34a8c4ca1ec003bbea2d4..a27213d921d9ca1ed0bda2b8cbe33e7eaea290f4 100644 (file)
@@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletRequest;
 
 import com.vaadin.Application;
 import com.vaadin.RootRequiresMoreInformationException;
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
+import com.vaadin.annotations.EagerInit;
 import com.vaadin.terminal.gwt.server.WebBrowser;
 import com.vaadin.ui.Root;
 
@@ -209,8 +209,8 @@ public interface WrappedRequest extends Serializable {
      * This information is only guaranteed to be available in some special
      * cases, for instance when {@link Application#getRoot} is called again
      * after throwing {@link RootRequiresMoreInformationException} or in
-     * {@link Root#init(WrappedRequest)} if the Root class is annotated with
-     * {@link RootInitRequiresBrowserDetails}
+     * {@link Root#init(WrappedRequest)} for a Root class not annotated with
+     * {@link EagerInit}
      * 
      * @return the browser details, or <code>null</code> if details are not
      *         available
index 1a67edebdeb600c19da891bb853b9402924165ee..4998baf90f5d96b84c6683f7a6886bf3e8d6366e 100644 (file)
@@ -18,7 +18,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.vaadin.Application;
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
+import com.vaadin.annotations.EagerInit;
 import com.vaadin.event.Action;
 import com.vaadin.event.Action.Handler;
 import com.vaadin.event.ActionManager;
@@ -60,9 +60,10 @@ import com.vaadin.ui.Window.CloseListener;
  * {@link #setContent(ComponentContainer)}.
  * </p>
  * <p>
- * If a {@link RootInitRequiresBrowserDetails} annotation is present on a class
- * extending <code>Root</code>, the framework will ensure {@link BrowserDetails}
- * are present in the {@link WrappedRequest} passed to the init method.
+ * If a {@link EagerInit} annotation is present on a class extending
+ * <code>Root</code>, the framework will use a faster initialization method
+ * which will not ensure that {@link BrowserDetails} are present in the
+ * {@link WrappedRequest} passed to the init method.
  * </p>
  * 
  * @see #init(WrappedRequest)
@@ -193,6 +194,15 @@ public abstract class Root extends AbstractComponentContainer implements
      * Helper class to emulate the main window from Vaadin 6 using roots. This
      * class should be used in the same way as Window used as a browser level
      * window in Vaadin 6 together with {@Application.LegacyApplication
+     * 
+     * 
+     * 
+     * 
+     * 
+     * 
+     * 
+     * 
+     * 
      * }
      */
     @Deprecated
@@ -1092,9 +1102,10 @@ public abstract class Root extends AbstractComponentContainer implements
      * <p>
      * The {@link WrappedRequest} can be used to get information about the
      * request that caused this root to be created. By default, the
-     * {@link BrowserDetails} are note guaranteed to be available in the
-     * request. Availability of the browser details can be requested by adding
-     * the {@link RootInitRequiresBrowserDetails} annotation to the class.
+     * {@link BrowserDetails} will be available in the request. If the browser
+     * details are not required, loading the application in the browser can take
+     * some shortcuts giving a faster initial rendering. This can be indicated
+     * by adding the {@link EagerInit} annotation to the Root class.
      * </p>
      * 
      * @param request
index 83d34e55af7a10c781a714105b702506043e02ef..36a793bd6dd9bad423de08a8538e77e69980cf26 100644 (file)
@@ -1,13 +1,11 @@
 package com.vaadin.tests.application;
 
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
 import com.vaadin.terminal.WrappedRequest;
 import com.vaadin.tests.components.AbstractTestApplication;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.Root;
 
 public class RefreshStatePreserve extends AbstractTestApplication {
-    @RootInitRequiresBrowserDetails
     public static class RefreshStateRoot extends Root {
         @Override
         public void init(WrappedRequest request) {
index f40de927772cb01c0a86c5e5debe6e72376f14fe..93bbc3995e423374b2f985a9b0ad4b44bda44126 100644 (file)
@@ -1,7 +1,7 @@
 package com.vaadin.tests.components.root;
 
 import com.vaadin.RootRequiresMoreInformationException;
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
+import com.vaadin.annotations.EagerInit;
 import com.vaadin.terminal.ExternalResource;
 import com.vaadin.terminal.WrappedRequest;
 import com.vaadin.terminal.WrappedRequest.BrowserDetails;
@@ -12,14 +12,13 @@ import com.vaadin.ui.Root;
 
 public class LazyInitRoots extends AbstractTestApplication {
 
-    @RootInitRequiresBrowserDetails
-    private static class LazyInitRoot extends Root {
+    @EagerInit
+    private static class EagerInitRoot extends Root {
         @Override
         public void init(WrappedRequest request) {
             BrowserDetails browserDetails = request.getBrowserDetails();
             getContent().addComponent(
-                    new Label("Lazy init root: "
-                            + browserDetails.getUriFragment()));
+                    new Label("Lazy init root: " + browserDetails));
         }
     }
 
@@ -41,9 +40,9 @@ public class LazyInitRoots extends AbstractTestApplication {
                 };
                 return root;
             }
-        } else if (request.getParameter("lazyInit") != null) {
+        } else if (request.getParameter("eagerInit") != null) {
             // Root inited on second request
-            return new LazyInitRoot();
+            return new EagerInitRoot();
         } else {
             // The standard root
             Root root = new Root() {
@@ -55,9 +54,9 @@ public class LazyInitRoots extends AbstractTestApplication {
                     lazyCreateLink.setTargetName("_blank");
                     addComponent(lazyCreateLink);
 
-                    Link lazyInitLink = new Link("Open lazyInit root",
+                    Link lazyInitLink = new Link("Open eagerInit root",
                             new ExternalResource(getURL()
-                                    + "?lazyInit#lazyInit"));
+                                    + "?eagerInit#eagerInit"));
                     lazyInitLink.setTargetName("_blank");
                     addComponent(lazyInitLink);
                 }
index 8d878044486c7f872dc7f91970b9e3450b934b5d..60781619966594f15a160996cec35416e866b62b 100644 (file)
@@ -1,13 +1,11 @@
 package com.vaadin.tests.components.root;
 
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
 import com.vaadin.terminal.WrappedRequest;
 import com.vaadin.tests.components.AbstractTestRoot;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Label;
 
-@RootInitRequiresBrowserDetails
 public class UriFragmentTest extends AbstractTestRoot {
 
     private final Label fragmentLabel = new Label();