private static String getBootstrapJS(JsonValue initialUIDL, BootstrapContext context) { boolean productionMode = context.getSession().getConfiguration() .isProductionMode(); String result = getBootstrapJS();
/** * Creates a new bootstrap resolver based on the given request and * session. * * @param ui * the ui to resolve for */ protected BootstrapUriResolver(UI ui) { servletPathToContextRoot = ui.getInternals() .getContextRootRelativePath(); VaadinSession session = ui.getSession(); DeploymentConfiguration config = session.getConfiguration(); if (session.getBrowser().isEs6Supported()) { frontendRootUrl = config.getEs6FrontendPrefix(); } else { frontendRootUrl = config.getEs5FrontendPrefix(); } assert frontendRootUrl.endsWith("/"); assert servletPathToContextRoot.endsWith("/"); }
@Override public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { // Check if the browser is supported WebBrowser browser = session.getBrowser(); final String cookie = request.getHeader("Cookie"); if (browser.isTooOldToFunctionProperly()) { // bypass if cookie set if (cookie == null || !cookie.contains(FORCE_LOAD_COOKIE)) { writeBrowserTooOldPage(request, response); return true; // request handled } } // check for trying to run ie11 in development mode if (browser.isIE() && !session.getConfiguration().isProductionMode()) { // bypass if cookie set if (cookie == null || !cookie.contains(FORCE_LOAD_COOKIE)) { writeIE11InDevelopmentModePage(response); return true; } } return false; // pass to next handler }
@Override public int setErrorParameter(BeforeEnterEvent event, ErrorParameter<NotFoundException> parameter) { String path = event.getLocation().getPath(); String additionalInfo = ""; if (parameter.hasCustomMessage()) { additionalInfo = "Reason: " + parameter.getCustomMessage(); } boolean productionMode = event.getUI().getSession().getConfiguration() .isProductionMode(); String template = getErrorHtml(productionMode); template = template.replace("{{path}}", path); template = template.replace("{{additionalInfo}}", additionalInfo); if (template.contains("{{routes}}")) { template = template.replace("{{routes}}", getRoutes(event)); } getElement().appendChild(new Html(template).getElement()); return HttpServletResponse.SC_NOT_FOUND; }
/** * Generates the initial UIDL message which is included in the initial * bootstrap page. * * @param ui * the UI for which the UIDL should be generated * @return a JSON object with the initial UIDL message */ protected static JsonObject getInitialUidl(UI ui) { JsonObject json = new UidlWriter().createUidl(ui, false); VaadinSession session = ui.getSession(); if (session.getConfiguration().isXsrfProtectionEnabled()) { writeSecurityKeyUIDL(json, session); } writePushIdUIDL(json, session); if (getLogger().isDebugEnabled()) { getLogger().debug("Initial UIDL: {}", json.asString()); } return json; }
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()); }
private static void appendWebComponentsPolyfills(Element head, BootstrapContext context) { VaadinSession session = context.getSession(); DeploymentConfiguration config = session.getConfiguration();
VaadinService vaadinService = session.getService(); DeploymentConfiguration deploymentConfiguration = session .getConfiguration(); final boolean productionMode = deploymentConfiguration .isProductionMode();