private static InputStream getInlineResourceStream(VaadinRequest request, String file) { InputStream stream = request.getService().getClassLoader() .getResourceAsStream(file); if (stream == null) { throw new IllegalStateException(String.format( "File '%s' for inline resource is not available through " + "the servlet context class loader.", file)); } return stream; }
/** * 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(); }
@Override public boolean handleSessionExpired(VaadinRequest request, VaadinResponse response) throws IOException { if (!ServletHelper.isRequestType(request, RequestType.UIDL)) { return false; } VaadinService service = request.getService(); service.writeUncachedStringResponse(response, JsonConstants.JSON_CONTENT_TYPE, VaadinService.createSessionExpiredJSON()); return true; }
/** * Returns the UI class mapped for servlet that handles the given request. * <p> * This method is protected for testing purposes. * * @param request * the request for the UI * @return the UI class for the request */ protected static Class<? extends UI> getUIClass(VaadinRequest request) { String uiClassName = request.getService().getDeploymentConfiguration() .getUIClassName(); if (uiClassName == null) { throw new BootstrapException( "Could not determine the uiClassName for the request path " + request.getPathInfo()); } ClassLoader classLoader = request.getService().getClassLoader(); try { return Class.forName(uiClassName, true, classLoader) .asSubclass(UI.class); } catch (ClassNotFoundException e) { throw new BootstrapException( "Vaadin Servlet mapped to the request path " + request.getPathInfo() + " cannot find the mapped UI class with name " + uiClassName, e); } }
/** * Gets the application id. * * The application id is defined by * {@link VaadinService#getMainDivId(VaadinSession, VaadinRequest)} * * @return the application id */ public String getAppId() { if (appId == null) { appId = getRequest().getService().getMainDivId(getSession(), getRequest()); } return appId; }
/** * Gets the push mode to use. * * @return the desired push mode */ public PushMode getPushMode() { if (pushMode == null) { pushMode = getUI().getPushConfiguration().getPushMode(); if (pushMode == null) { pushMode = getRequest().getService() .getDeploymentConfiguration().getPushMode(); } if (pushMode.isEnabled() && !getRequest().getService().ensurePushAvailable()) { /* * Fall back if not supported (ensurePushAvailable will log * information to the developer the first time this happens) */ pushMode = PushMode.DISABLED; } } return pushMode; }
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); }
if (request.getService().getDeploymentConfiguration() .isSyncIdCheckEnabled()) { syncId = (int) json