private static Element createDependencyElement( BootstrapUriResolver resolver, LoadMode loadMode, JsonObject dependency, Dependency.Type type) { boolean inlineElement = loadMode == LoadMode.INLINE; String url = dependency.hasKey(Dependency.KEY_URL) ? resolver.resolveVaadinUri( dependency.getString(Dependency.KEY_URL)) : null; final Element dependencyElement; switch (type) { case STYLESHEET: dependencyElement = createStylesheetElement(url); break; case JAVASCRIPT: dependencyElement = createJavaScriptElement(url, !inlineElement); break; case HTML_IMPORT: dependencyElement = createHtmlImportElement(url); break; default: throw new IllegalStateException( "Unsupported dependency type: " + type); } if (inlineElement) { dependencyElement.appendChild( new DataNode(dependency.getString(Dependency.KEY_CONTENTS), dependencyElement.baseUri())); } return dependencyElement; }
head.appendChild( createJavaScriptElement(context.getUriResolver() .resolveVaadinUri(es5AdapterUrl), false)); .resolveVaadinUri(webcomponentsLoaderUrl); head.appendChild(createJavaScriptElement(resolvedUrl, false));
private static String getClientEngineUrl(BootstrapContext context) { // use nocache version of client engine if it // has been compiled by SDM or eclipse // In production mode, this should really be loaded by the static block // so emit a warning if we get here (tests will always get here) final boolean productionMode = context.getSession().getConfiguration() .isProductionMode(); boolean resolveNow = !productionMode || getClientEngine() == null; if (resolveNow && ClientResourcesUtils.getResource( "/META-INF/resources/" + CLIENT_ENGINE_NOCACHE_FILE) != null) { return context.getUriResolver().resolveVaadinUri( "context://" + CLIENT_ENGINE_NOCACHE_FILE); } if (getClientEngine() == null) { throw new BootstrapException( "Client engine file name has not been resolved during initialization"); } return context.getUriResolver() .resolveVaadinUri("context://" + getClientEngine()); }
/** * Gets the URI resolver to use for bootstrap resources. * * @return the URI resolver */ public BootstrapUriResolver getUriResolver() { if (uriResolver == null) { uriResolver = new BootstrapUriResolver(getUI()); } return uriResolver; }
private static String createImportLink( BootstrapUriResolver bootstrapUriResolver, String href) { String resolvedLink = bootstrapUriResolver.resolveVaadinUri(href); return "<link rel=\"import\" href=\"" + resolvedLink + "\">"; }