/** * Retrieves the wrapped session for the request. * * @param request * The request for which to retrieve a session * @param requestCanCreateSession * true to create a new session if one currently does not exist * @return The retrieved (or created) wrapped session * @throws SessionExpiredException * If the request is not associated to a session and new session * creation is not allowed */ private WrappedSession getWrappedSession(VaadinRequest request, boolean requestCanCreateSession) throws SessionExpiredException { final WrappedSession session = request .getWrappedSession(requestCanCreateSession); if (session == null) { throw new SessionExpiredException(); } return session; }
/** * Finds the {@link UI} that belongs to the provided request. This is * generally only supported for UIDL requests as other request types are not * related to any particular UI or have the UI information encoded in a * non-standard way. The returned UI is also set as the current UI ( * {@link UI#setCurrent(UI)}). * * @param request * the request for which a UI is desired * @return the UI belonging to the request or null if no UI is found */ public UI findUI(VaadinRequest request) { // getForSession asserts that the lock is held VaadinSession session = loadSession(request.getWrappedSession()); // Get UI id from the request String uiIdString = request .getParameter(ApplicationConstants.UI_ID_PARAMETER); UI ui = null; if (uiIdString != null && session != null) { int uiId = Integer.parseInt(uiIdString); ui = session.getUIById(uiId); } UI.setCurrent(ui); return ui; }
assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread"; closeSession(session, request.getWrappedSession(false)); return null; } else if (restartApplication) { closeSession(session, request.getWrappedSession(false)); return createAndRegisterSession(request); } else {
WrappedSession oldSession = request.getWrappedSession(); WrappedSession newSession = request.getWrappedSession();
/** * Creates and registers a new VaadinSession for this service. Assumes * proper locking has been taken care of by the caller. * * @param request * The request which triggered session creation. * @return A new VaadinSession instance */ private VaadinSession createAndRegisterSession(VaadinRequest request) { assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread"; VaadinSession session = createVaadinSession(request); VaadinSession.setCurrent(session); storeSession(session, request.getWrappedSession()); // Initial WebBrowser data comes from the request session.getBrowser().updateRequestDetails(request); session.setConfiguration(getDeploymentConfiguration()); // Initial locale comes from the request if (getInstantiator().getI18NProvider() != null) { setLocale(request, session); } onVaadinSessionStarted(request, session); return session; }