@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; }
/** * Call the session's error handler. */ private void callErrorHandler(VaadinSession session, Exception e) { session.getErrorHandler().error(new ErrorEvent(e)); }
/** * Updates the transient session lock from VaadinService. */ private void refreshLock() { assert lock == null || lock == service.getSessionLock( session) : "Cannot change the lock from one instance to another"; assert hasLock(service, session); lock = service.getSessionLock(session); }
public RouteRegistry getRegistry() { // If we have a session then return the session registry // else return router registry if (VaadinSession.getCurrent() != null) { return SessionRouteRegistry .getSessionRegistry(VaadinSession.getCurrent()); } return registry; }
private void cleanStreamVariable(VaadinSession session, StreamReceiver streamReceiver) { session.lock(); try { session.getResourceRegistry().unregisterResource(streamReceiver); } finally { session.unlock(); } }
@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (!canHandleRequest(request)) { return false; } session.lock(); try { return synchronizedHandleRequest(session, request, response); } finally { session.unlock(); } }
private static List<Element> setupDocumentHead(Element head, BootstrapContext context) { setupMetaAndTitle(head, context); setupCss(head, context); JsonObject initialUIDL = getInitialUidl(context.getUI()); Map<LoadMode, JsonArray> dependenciesToProcessOnServer = popDependenciesToProcessOnServer( initialUIDL); setupFrameworkLibraries(head, initialUIDL, context); return applyUserDependencies(head, context, dependenciesToProcessOnServer); }
private InputStream createInputStream(VaadinSession session) { session.lock(); try { return factory.createInputStream(); } finally { session.unlock(); } }
@Override public String getServiceName() { return getServlet().getServletName(); }
/** * Called when the VaadinSession should be removed from the underlying HTTP * session. * * @param wrappedSession * the underlying HTTP session */ public void removeSession(WrappedSession wrappedSession) { assert VaadinSession.hasLock(this, wrappedSession); removeFromHttpSession(wrappedSession); }
private static String getSessionDetails(VaadinSession session) { if (session == null) { return null; } else { return session + " for " + session.getService().getServiceName(); } }
/** * 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; }
private List<PwaIcon> initializeIcons(BufferedImage baseImage, int bgColor) { for (PwaIcon icon : getIconTemplates(pwaConfiguration.getIconPath())) { // New image with wanted size icon.setImage(drawIconImage(baseImage, bgColor, icon)); // Store byte array and hashcode of image (GeneratedImage) icons.add(icon); } return icons; }
@Override public boolean handleSessionExpired(VaadinRequest request, VaadinResponse response) throws IOException { if (!ServletHelper.isRequestType(request, RequestType.HEARTBEAT)) { return false; } response.sendError(HttpServletResponse.SC_GONE, "Session expired"); return true; } }
/** * Creates a Vaadin request for a http servlet request. This method can be * overridden if the Vaadin request should have special properties. * * @param request * the original http servlet request * @return a Vaadin request for the original request */ protected VaadinServletRequest createVaadinRequest( HttpServletRequest request) { return new VaadinServletRequest(request, getService()); }
/** * Performs the actual removal of the VaadinSession from the underlying HTTP * session after sanity checks have been performed. * * @param wrappedSession * the underlying HTTP session */ protected void removeFromHttpSession(WrappedSession wrappedSession) { wrappedSession.removeAttribute(getSessionAttributeName()); }
private VaadinServletResponse createVaadinResponse( HttpServletResponse response) { return new VaadinServletResponse(response, getService()); }
@Override public WrappedSession getWrappedSession(boolean allowSessionCreation) { HttpSession session = getSession(allowSessionCreation); if (session != null) { return new WrappedHttpSession(session); } else { return null; } }
/** * Gets the URI resolver to use for bootstrap resources. * * @return the URI resolver */ public BootstrapUriResolver getUriResolver() { if (uriResolver == null) { uriResolver = new BootstrapUriResolver(getUI()); } return uriResolver; }
private static RouteRegistry getSessionRegistry() { return SessionRouteRegistry .getSessionRegistry(VaadinSession.getCurrent()); }