private static List<Element> applyUserDependencies(Element head, BootstrapContext context, Map<LoadMode, JsonArray> dependenciesToProcessOnServer) { List<Element> dependenciesToInlineInBody = new ArrayList<>(); for (Map.Entry<LoadMode, JsonArray> entry : dependenciesToProcessOnServer .entrySet()) { dependenciesToInlineInBody.addAll( inlineDependenciesInHead(head, context.getUriResolver(), entry.getKey(), entry.getValue())); } return dependenciesToInlineInBody; }
private static ThemeSettings getThemeSettings( BootstrapHandler.BootstrapContext context, ThemeDefinition themeDefinition) { ThemeSettings settings = new ThemeSettings(); Class<? extends AbstractTheme> themeClass = themeDefinition.getTheme(); AbstractTheme theme = ReflectTools.createInstance(themeClass); if (!context.isProductionMode()) { List<JsonObject> head = Stream .of(themeClass.getAnnotationsByType(HtmlImport.class)) .map(HtmlImport::value) .map(url -> createImportLink(context.getUriResolver(), url)) .map(BootstrapUtils::createInlineDependencyObject) .collect(Collectors.toList()); settings.setHeadContents(head); } settings.setHeadInjectedContent(createHeaderInlineScript(theme)); settings.setBodyAttributes( theme.getBodyAttributes(themeDefinition.getVariant())); return settings; }
private static Element createDependencyElement(BootstrapContext context, JsonObject dependencyJson) { String type = dependencyJson.getString(Dependency.KEY_TYPE); if (Dependency.Type.contains(type)) { Dependency.Type dependencyType = Dependency.Type.valueOf(type); return createDependencyElement(context.getUriResolver(), LoadMode.INLINE, dependencyJson, dependencyType); } return Jsoup.parse(dependencyJson.getString(Dependency.KEY_CONTENTS), "", Parser.xmlParser()); }
context.getRequest(), context.getSession(), context.getResponse(), document, context.getUI(), context.getUriResolver()); context.getSession().getService().modifyBootstrapPage(response);
createJavaScriptElement(context.getUriResolver() .resolveVaadinUri(es5AdapterUrl), false)); String resolvedUrl = context.getUriResolver() .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()); }