/** * Determines if Flow should use compiled or original frontend resources. * * User can explicitly disable bundled resources usage by setting the * {@link Constants#USE_ORIGINAL_FRONTEND_RESOURCES} property to * {@code true}. * * @return {@code true} if Flow should use compiled frontend resources. */ default boolean useCompiledFrontendResources() { return isProductionMode() && !getBooleanProperty( Constants.USE_ORIGINAL_FRONTEND_RESOURCES, false); }
/** * Writes cache headers for the file into the response. * * @param filenameWithPath * the name and path of the file being sent * @param response * the response object */ protected void writeCacheHeaders(String filenameWithPath, HttpServletResponse response) { int resourceCacheTime = getCacheTime(filenameWithPath); String cacheControl; if (!deploymentConfiguration.isProductionMode()) { cacheControl = "no-cache"; } else if (resourceCacheTime > 0) { cacheControl = "max-age=" + resourceCacheTime; } else { cacheControl = "public, max-age=0, must-revalidate"; } response.setHeader("Cache-Control", cacheControl); }
/** * 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(); }
/** * Potentially checks whether this session is currently locked by the * current thread, and fails with the given message if not. * <p> * When production mode is enabled, the check is only done if assertions are * also enabled. This is done to avoid the small performance impact of * continuously checking the lock status. The check is always done when * production mode is not enabled. * * @param message * the error message to include when failing if the check is done * and the session is not locked */ public void checkHasLock(String message) { if (configuration == null || configuration.isProductionMode()) { assert hasLock() : message; } else if (!hasLock()) { throw new IllegalStateException(message); } }
private static String getBootstrapJS(JsonValue initialUIDL, BootstrapContext context) { boolean productionMode = context.getSession().getConfiguration() .isProductionMode(); String result = getBootstrapJS(); JsonObject appConfig = context.getApplicationParameters();
@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; }
private void reportException(Exception exception, String path, String exceptionText) { getElement().appendChild(Element.createText(exceptionText)); VaadinService vaadinService = VaadinService.getCurrent(); // Check that we have a vaadinService as else we will fail on a NPE and // the stacktrace we actually got will disappear and getting a NPE is // confusing. boolean productionMode = vaadinService != null && vaadinService .getDeploymentConfiguration().isProductionMode(); if (!productionMode) { checkLogBinding(); printStacktrace(exception); } getLogger().error( "There was an exception while trying to navigate to '{}'", path, exception); }
.collect(Collectors.toList()); if (!getDeploymentConfiguration().isProductionMode()) { Logger logger = getLogger(); logger.debug("The application has the following routes: ");
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 pushJSPath = ServletHelper.getContextRootRelativePath(request) + "/"; if (request.getService().getDeploymentConfiguration() .isProductionMode()) { pushJSPath += ApplicationConstants.VAADIN_PUSH_JS; } else { pushJSPath += ApplicationConstants.VAADIN_PUSH_DEBUG_JS; } pushJSPath += versionQueryParam; return createJavaScriptElement(pushJSPath); }
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()); }
.getConfiguration(); final boolean productionMode = deploymentConfiguration .isProductionMode();