aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-12-22 11:23:20 +0200
committerLeif Åstrand <leif@vaadin.com>2011-12-22 11:23:29 +0200
commitd9f5e4c8054fa3d99f30640c9ac44eb8e850fe50 (patch)
tree854afe6fe9ed82d2f85cf43a2468b88a2594adda
parentbf94e8c41705d1ff5e71f8a757e7a1789bf40aa0 (diff)
downloadvaadin-framework-d9f5e4c8054fa3d99f30640c9ac44eb8e850fe50.tar.gz
vaadin-framework-d9f5e4c8054fa3d99f30640c9ac44eb8e850fe50.zip
Change the default to a two request bootstrap
Add @EagerInit annotation to indicate that that no browser details are required, enabling a one request bootstrap.
-rw-r--r--src/com/vaadin/Application.java6
-rw-r--r--src/com/vaadin/annotations/EagerInit.java (renamed from src/com/vaadin/annotations/RootInitRequiresBrowserDetails.java)17
-rw-r--r--src/com/vaadin/terminal/WrappedRequest.java6
-rw-r--r--src/com/vaadin/ui/Root.java25
-rw-r--r--tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java17
-rw-r--r--tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java2
7 files changed, 38 insertions, 37 deletions
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java
index 700f657937..bc2575a5fe 100644
--- a/src/com/vaadin/Application.java
+++ b/src/com/vaadin/Application.java
@@ -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/RootInitRequiresBrowserDetails.java b/src/com/vaadin/annotations/EagerInit.java
index bd04d2e430..0e9fbdb314 100644
--- a/src/com/vaadin/annotations/RootInitRequiresBrowserDetails.java
+++ b/src/com/vaadin/annotations/EagerInit.java
@@ -1,7 +1,3 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
package com.vaadin.annotations;
import java.lang.annotation.ElementType;
@@ -13,11 +9,10 @@ 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.
+ * 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()
@@ -27,6 +22,6 @@ import com.vaadin.ui.Root;
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
-public @interface RootInitRequiresBrowserDetails {
- // No methods
+public @interface EagerInit {
+ // No values
}
diff --git a/src/com/vaadin/terminal/WrappedRequest.java b/src/com/vaadin/terminal/WrappedRequest.java
index 235a0513c7..a27213d921 100644
--- a/src/com/vaadin/terminal/WrappedRequest.java
+++ b/src/com/vaadin/terminal/WrappedRequest.java
@@ -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
diff --git a/src/com/vaadin/ui/Root.java b/src/com/vaadin/ui/Root.java
index 1a67edebde..4998baf90f 100644
--- a/src/com/vaadin/ui/Root.java
+++ b/src/com/vaadin/ui/Root.java
@@ -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
diff --git a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
index 83d34e55af..36a793bd6d 100644
--- a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
+++ b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
@@ -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) {
diff --git a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java
index f40de92777..93bbc3995e 100644
--- a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java
+++ b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java
@@ -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);
}
diff --git a/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java b/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java
index 8d87804448..6078161996 100644
--- a/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java
+++ b/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java
@@ -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();