diff options
author | Leif Åstrand <legioth@gmail.com> | 2017-03-07 11:13:57 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-03-07 11:13:57 +0200 |
commit | 9ca5a0b160a7b3981ab7b522dafebb3eabeeb0da (patch) | |
tree | e1a0727d6e4a46104359d7bff1c1803d99950619 /client | |
parent | e3d14322cab755ce195676c9dcad4d1982d5c9be (diff) | |
download | vaadin-framework-9ca5a0b160a7b3981ab7b522dafebb3eabeeb0da.tar.gz vaadin-framework-9ca5a0b160a7b3981ab7b522dafebb3eabeeb0da.zip |
Always load the deferred connector bundle (#8713)
endDependencyLoading that was used for starting to load the deferred
connector bundle is only called during regular application init if the
theme wasn't yet loaded when the initial UIDL request finished.
With this patch, the bundle is instead set to be loaded after the
initial UIDL message has been completely processed.
Fixes #4763
Diffstat (limited to 'client')
3 files changed, 51 insertions, 18 deletions
diff --git a/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java b/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java index cde31cbd40..9a8fce9b56 100644 --- a/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java @@ -48,8 +48,6 @@ import com.vaadin.client.debug.internal.TestBenchSection; import com.vaadin.client.debug.internal.VDebugWindow; import com.vaadin.client.debug.internal.theme.DebugWindowStyles; import com.vaadin.client.event.PointerEventSupport; -import com.vaadin.client.metadata.BundleLoadCallback; -import com.vaadin.client.metadata.ConnectorBundleLoader; import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.TypeData; import com.vaadin.client.ui.UnknownComponentConnector; @@ -662,22 +660,6 @@ public class ApplicationConfiguration implements EntryPoint { cmd.execute(); } callbacks.clear(); - } else if (dependenciesLoading == 0 && !ConnectorBundleLoader.get() - .isBundleLoaded(ConnectorBundleLoader.DEFERRED_BUNDLE_NAME)) { - ConnectorBundleLoader.get().loadBundle( - ConnectorBundleLoader.DEFERRED_BUNDLE_NAME, - new BundleLoadCallback() { - @Override - public void loaded() { - // Nothing to do - } - - @Override - public void failed(Throwable reason) { - getLogger().log(Level.SEVERE, - "Error loading deferred bundle", reason); - } - }); } } diff --git a/client/src/main/java/com/vaadin/client/communication/MessageHandler.java b/client/src/main/java/com/vaadin/client/communication/MessageHandler.java index 5057d574fa..152ea79db7 100644 --- a/client/src/main/java/com/vaadin/client/communication/MessageHandler.java +++ b/client/src/main/java/com/vaadin/client/communication/MessageHandler.java @@ -58,6 +58,7 @@ import com.vaadin.client.VConsole; import com.vaadin.client.ValueMap; import com.vaadin.client.WidgetUtil; import com.vaadin.client.extensions.AbstractExtensionConnector; +import com.vaadin.client.metadata.ConnectorBundleLoader; import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Property; import com.vaadin.client.metadata.Type; @@ -565,6 +566,8 @@ public class MessageHandler { endRequestIfResponse(json); resumeResponseHandling(lock); + ConnectorBundleLoader.get().ensureDeferredBundleLoaded(); + if (Profiler.isEnabled()) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override diff --git a/client/src/main/java/com/vaadin/client/metadata/ConnectorBundleLoader.java b/client/src/main/java/com/vaadin/client/metadata/ConnectorBundleLoader.java index 6a0bd3c030..8b3e53aea0 100644 --- a/client/src/main/java/com/vaadin/client/metadata/ConnectorBundleLoader.java +++ b/client/src/main/java/com/vaadin/client/metadata/ConnectorBundleLoader.java @@ -17,7 +17,10 @@ package com.vaadin.client.metadata; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import com.google.gwt.core.client.JsArrayString; import com.google.gwt.core.shared.GWT; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Display; @@ -208,4 +211,49 @@ public abstract class ConnectorBundleLoader { s.setVisibility(Visibility.VISIBLE); s.setMargin(0, Unit.PX); } + + /** + * Starts loading the deferred bundle if it hasn't already been started. + */ + public void ensureDeferredBundleLoaded() { + if (!isBundleLoaded(DEFERRED_BUNDLE_NAME)) { + loadBundle(DEFERRED_BUNDLE_NAME, new BundleLoadCallback() { + @Override + public void loaded() { + // Nothing to do + } + + @Override + public void failed(Throwable reason) { + getLogger().log(Level.SEVERE, + "Error loading deferred bundle", reason); + } + }); + } + } + + private static Logger getLogger() { + return Logger.getLogger(ConnectorBundleLoader.class.getName()); + } + + /** + * Gets a list of all currently loaded bundle names. + * <p> + * This method is intended for testing the loading mechanism. + * + * @return a list of bundles, not <code>null</code> + */ + public List<String> getLoadedBundles() { + ArrayList<String> bundles = new ArrayList<>(); + + JsArrayString keys = asyncBlockLoaders.getKeys(); + for (int i = 0; i < keys.length(); i++) { + String bundleName = keys.get(i); + if (isBundleLoaded(bundleName)) { + bundles.add(bundleName); + } + } + + return bundles; + } } |