protected void appendMainScriptTagContents(BootstrapContext context, StringBuilder builder) throws IOException { JsonObject appConfig = context.getApplicationParameters(); boolean isDebug = !context.getSession().getConfiguration() .isProductionMode(); if (isDebug) { /* * Add tracking needed for getting bootstrap metrics to the client * side Profiler if another implementation hasn't already been * added. */ builder.append( "if (typeof window.__gwtStatsEvent != 'function') {\n"); builder.append("vaadin.gwtStatsEvents = [];\n"); builder.append( "window.__gwtStatsEvent = function(event) {vaadin.gwtStatsEvents.push(event); return true;};\n"); builder.append("}\n"); } builder.append("vaadin.initApplication(\""); builder.append(context.getAppId()); builder.append("\","); appendJsonObject(builder, appConfig, isDebug); builder.append(");\n"); }
/** * Adds the performance timing data (used by TestBench 3) to the UIDL * response. * * @throws IOException */ private void writePerformanceData(UI ui, Writer writer) throws IOException { if (!ui.getSession().getService().getDeploymentConfiguration() .isProductionMode()) { writer.write(String.format(", \"timings\":[%d, %d]", ui.getSession().getCumulativeRequestDuration(), ui.getSession().getLastRequestDuration())); } }
if (getService().getDeploymentConfiguration().isProductionMode()) {
.isProductionMode()) { pushJS += ApplicationConstants.VAADIN_PUSH_JS; } else {
/** * Checks if the application is running in production mode. * * @return <code>true</code> if in production mode, <code>false</code> * otherwise. */ public boolean isProductionMode() { return request.getService().getDeploymentConfiguration() .isProductionMode(); }
private static String getBootstrapJS(JsonValue initialUIDL, BootstrapContext context) { boolean productionMode = context.getSession().getConfiguration() .isProductionMode(); String result = getBootstrapJS(); JsonObject appConfig = context.getApplicationParameters(); int indent = 0; if (!productionMode) { indent = 4; } String appConfigString = JsonUtil.stringify(appConfig, indent); String initialUIDLString = JsonUtil.stringify(initialUIDL, indent); // Browser interpret </script> as end of script no matter if it is // inside a string or not so we must escape it initialUIDLString = scriptEndTagPattern.matcher(initialUIDLString) .replaceAll("<\\\\x2F$1"); if (!productionMode) { // only used in debug mode by profiler result = result.replace("{{GWT_STAT_EVENTS}}", GWT_STAT_EVENTS_JS); } else { result = result.replace("{{GWT_STAT_EVENTS}}", ""); } result = result.replace("{{APP_ID}}", context.getAppId()); result = result.replace("{{INITIAL_UIDL}}", initialUIDLString); result = result.replace("{{CONFIG_JSON}}", appConfigString); return result; }
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 || clientEngineFile == null; if (resolveNow && BootstrapHandler.class.getResource( "/META-INF/resources/" + CLIENT_ENGINE_NOCACHE_FILE) != null) { return context.getUriResolver().resolveVaadinUri( "context://" + CLIENT_ENGINE_NOCACHE_FILE); } if (clientEngineFile == null) { throw new BootstrapException( "Client engine file name has not been resolved during initialization"); } return context.getUriResolver() .resolveVaadinUri("context://" + clientEngineFile); }
private static Element getPushScript(BootstrapContext context) { VaadinRequest request = context.getRequest(); // Parameter appended to JS to bypass caches after version upgrade. String versionQueryParam = "?v=" + Version.getFullVersion(); // Load client-side dependencies for push support String pushJS = ServletHelper.getContextRootRelativePath(request) + "/"; if (request.getService().getDeploymentConfiguration() .isProductionMode()) { pushJS += ApplicationConstants.VAADIN_PUSH_JS; } else { pushJS += ApplicationConstants.VAADIN_PUSH_DEBUG_JS; } pushJS += versionQueryParam; return new Element(Tag.valueOf("script"), "") .attr("type", TYPE_TEXT_JAVASCRIPT).attr("src", pushJS); }
context.getUriResolver().getFrontendUrl()); if (!session.getConfiguration().isProductionMode()) { appConfig.put("debug", true);
VaadinService vaadinService = request.getService(); final boolean productionMode = session.getConfiguration() .isProductionMode();