aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/Application.java
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-11-28 13:42:02 +0200
committerLeif Åstrand <leif@vaadin.com>2011-11-28 13:42:02 +0200
commit6063d00f5ae6f0cb5c5eaf0c3ce2998c5aa88a2b (patch)
tree218c6fb4f62f20325d25aeed94b38338b7708f33 /src/com/vaadin/Application.java
parentcb5f080e5337c081f22eea86c0cf170ef88a2257 (diff)
downloadvaadin-framework-6063d00f5ae6f0cb5c5eaf0c3ce2998c5aa88a2b.tar.gz
vaadin-framework-6063d00f5ae6f0cb5c5eaf0c3ce2998c5aa88a2b.zip
Add support for deferred Root init and early widgetset loading
Diffstat (limited to 'src/com/vaadin/Application.java')
-rw-r--r--src/com/vaadin/Application.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java
index d284492c1c..874455f3c0 100644
--- a/src/com/vaadin/Application.java
+++ b/src/com/vaadin/Application.java
@@ -27,6 +27,7 @@ import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import com.vaadin.annotations.RootInitRequiresBrowserDetals;
import com.vaadin.service.ApplicationContext;
import com.vaadin.terminal.ApplicationResource;
import com.vaadin.terminal.CombinedRequest;
@@ -1700,9 +1701,10 @@ public class Application implements Terminal.ErrorListener, Serializable {
synchronized (this) {
PendingRootRequest pendingRootRequest = pendingRoots.remove(rootId);
- if (pendingRootRequest == null && rootId != null) {
- root = roots.get(rootId);
- } else {
+ root = roots.get(rootId);
+ if (root == null) {
+ // We don't have no root yet
+ // Throws exception if root can not yet be created
root = getRoot(request);
if (root.getApplication() == null) {
root.setApplication(this);
@@ -1712,10 +1714,18 @@ public class Application implements Terminal.ErrorListener, Serializable {
root.setRootId(id);
roots.put(Integer.valueOf(root.getRootId()), root);
- // TODO implement lazy init of root if indicated by
- // annotation
- root.init(request);
+ if (pendingRootRequest == null
+ && root.getClass().isAnnotationPresent(
+ RootInitRequiresBrowserDetals.class)) {
+ pendingRoots.put(Integer.valueOf(id),
+ new PendingRootRequest(request));
+ } else {
+ root.init(request);
+ }
}
+ } else if (pendingRootRequest != null) {
+ // We have a root, but the init has been pending
+ root.init(request);
}
}
@@ -1735,4 +1745,8 @@ public class Application implements Terminal.ErrorListener, Serializable {
: new Integer(rootIdString);
return rootId;
}
+
+ public boolean isRootInitPending(int rootId) {
+ return pendingRoots.containsKey(Integer.valueOf(rootId));
+ }
}