]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make code splitting work (#8636) 29/329/1
authorLeif Åstrand <leif@vaadin.com>
Thu, 22 Nov 2012 07:54:50 +0000 (09:54 +0200)
committerLeif Åstrand <leif@vaadin.com>
Thu, 22 Nov 2012 07:55:00 +0000 (09:55 +0200)
Change-Id: I25c1494d29d20c89dc9c259995ed4b87067e859b

client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java
client/src/com/vaadin/client/metadata/TypeDataBundle.java [deleted file]

index 652eb38b5cf14ba33543687935eb9c32aa6b97f8..9d833f51bb3ccd37b531c5ab18dac752f5a867e7 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.RunAsyncCallback;
 import com.google.gwt.core.ext.Generator;
 import com.google.gwt.core.ext.GeneratorContext;
 import com.google.gwt.core.ext.TreeLogger;
@@ -34,7 +35,6 @@ import com.vaadin.client.metadata.ConnectorBundleLoader;
 import com.vaadin.client.metadata.InvokationHandler;
 import com.vaadin.client.metadata.ProxyHandler;
 import com.vaadin.client.metadata.TypeData;
-import com.vaadin.client.metadata.TypeDataBundle;
 import com.vaadin.client.metadata.TypeDataStore;
 import com.vaadin.client.ui.UnknownComponentConnector;
 import com.vaadin.server.widgetsetutils.metadata.ClientRpcVisitor;
@@ -131,12 +131,21 @@ public class ConnectorBundleLoaderFactory extends Generator {
                 w.print(".runAsync(");
             }
 
-            w.print("new ");
-            w.print(TypeDataBundle.class.getName());
-            w.println("(getName()) {");
+            w.println("new %s() {", RunAsyncCallback.class.getName());
             w.indent();
 
-            w.println("public void load() {");
+            w.println("public void onSuccess() {");
+            w.indent();
+
+            w.println("load();");
+            w.println("%s.get().setLoaded(getName());",
+                    ConnectorBundleLoader.class.getName());
+
+            // Close onSuccess method
+            w.outdent();
+            w.println("}");
+
+            w.println("private void load() {");
             w.indent();
 
             printBundleData(logger, w, bundle);
@@ -145,7 +154,16 @@ public class ConnectorBundleLoaderFactory extends Generator {
             w.outdent();
             w.println("}");
 
-            // Close new TypeDataBundle() {}
+            w.println("public void onFailure(Throwable reason) {");
+            w.indent();
+
+            w.println("%s.get().setLoadFailure(getName(), reason);",
+                    ConnectorBundleLoader.class.getName());
+
+            w.outdent();
+            w.println("}");
+
+            // Close new RunAsyncCallback() {}
             w.outdent();
             w.print("}");
 
index 0549547e386114477797c5083c7a1a75bdc6160e..8c42bdfc4d1f14c561e88e39afc267d291760c12 100644 (file)
@@ -78,6 +78,8 @@ public abstract class ConnectorBundleLoader {
     }
 
     public void setLoadFailure(String bundleName, Throwable reason) {
+        reason = new RuntimeException("Failed to load bundle " + bundleName
+                + ": " + reason.getMessage(), reason);
         List<BundleLoadCallback> callbacks = asyncBlockLoaders.get(bundleName)
                 .setError(reason);
         for (BundleLoadCallback callback : callbacks) {
diff --git a/client/src/com/vaadin/client/metadata/TypeDataBundle.java b/client/src/com/vaadin/client/metadata/TypeDataBundle.java
deleted file mode 100644 (file)
index 96f4884..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* 
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.client.metadata;
-
-import com.google.gwt.core.client.RunAsyncCallback;
-
-public abstract class TypeDataBundle implements RunAsyncCallback {
-    private final String name;
-
-    public TypeDataBundle(String name) {
-        this.name = name;
-    }
-
-    @Override
-    public void onSuccess() {
-        ConnectorBundleLoader loader = ConnectorBundleLoader.get();
-        load();
-        loader.setLoaded(getName());
-    }
-
-    @Override
-    public void onFailure(Throwable reason) {
-        ConnectorBundleLoader.get().setLoadFailure(
-                getName(),
-                new RuntimeException("Failed to load bundle " + getName()
-                        + ": " + reason.getMessage(), reason));
-    }
-
-    public abstract void load();
-
-    public String getName() {
-        return name;
-    }
-}