Refine search
+ uiId + "). "; if (getSession() != null && !getSession().equals(VaadinSession.getCurrent())) { message += "Furthermore, it is already attached to another VaadinSession. "; setTheme(request.getParameter("theme")); getPage().init(request); .getAttribute(ApplicationConstants.UI_ROOT_PATH); if (uiPathInfo != null) { setUiPathInfo(uiPathInfo); if (getSession() != null && getSession().getConfiguration() != null && getSession().getConfiguration().isSendUrlsAsParameters() && getPage().getLocation() != null) { } else if (request.getPathInfo() != null) {
private LegacyApplication getApplication() { LegacyApplication application = VaadinSession.getCurrent() .getAttribute(LegacyApplication.class); if (application == null) { application = createApplication(); if (application == null) { return null; } VaadinSession.getCurrent().setAttribute(LegacyApplication.class, application); URL applicationUrl; try { applicationUrl = VaadinService.getCurrent() .getApplicationUrl(VaadinService.getCurrentRequest()); } catch (MalformedURLException e) { throw new RuntimeException(e); } application.doInit(applicationUrl); } if (application != null && !application.isRunning()) { VaadinSession.getCurrent().setAttribute(LegacyApplication.class, null); // Run again without a current application return getApplication(); } return application; }
/** * Closes those UIs in the given session for which {@link #isUIActive} * yields false. * * @since 7.0.0 */ private void closeInactiveUIs(VaadinSession session) { final String sessionId = session.getSession().getId(); for (final UI ui : session.getUIs()) { if (!isUIActive(ui) && !ui.isClosing()) { ui.accessSynchronously(() -> { getLogger().log(Level.FINE, "Closing inactive UI #{0} in session {1}", new Object[] { ui.getUIId(), sessionId }); ui.close(); }); } } }
/** * Checks whether there might be some {@link VaadinSession} other than the * provided one for which the current thread holds a lock. This method might * not detect all cases where some other session is locked, but it should * cover the most typical situations. * * @since 7.2 * @param session * the session that is expected to be locked * @return <code>true</code> if another session is also locked by the * current thread; <code>false</code> if no such session was found */ public static boolean isOtherSessionLocked(VaadinSession session) { VaadinSession otherSession = VaadinSession.getCurrent(); if (otherSession == null || otherSession == session) { return false; } return otherSession.hasLock(); }
public void doInit(URL url) { this.url = url; VaadinSession.getCurrent().setErrorHandler(this); init(); }
/** * Returns whether the given session is active or whether it can be closed. * <p> * A session is active if and only if its {@link VaadinSession#getState()} * returns {@link State#OPEN} and * {@link #getUidlRequestTimeout(VaadinSession) getUidlRequestTimeout} is * negative or has not yet expired. * * @param session * The session whose status to check * * @return true if the session is active, false if it could be closed. */ private boolean isSessionActive(VaadinSession session) { if (session.getState() != State.OPEN || session.getSession() == null) { return false; } else { long now = System.currentTimeMillis(); int timeout = 1000 * getUidlRequestTimeout(session); return timeout < 0 || now - session.getLastRequestTimestamp() < timeout; } }
@Override public void onClick(PointClickEvent event) { Module module = moduleMap.get(event.getCategory()); VaadinSession.getCurrent().setAttribute("module", module); VaadinSession.getCurrent().setAttribute("tab", TopologyViewPanel.CATEGORISED_ERROR_TAB); UI.getCurrent().getNavigator().navigateTo("topologyView"); } });
VaadinRequest request) { if (component == null) { component = UI.getCurrent(); session = VaadinSession.getCurrent(); Locale locale = session.getLocale(); if (locale != null) { return locale; Locale locale = request.getLocale(); if (locale != null) { return locale;
try { session = service.findVaadinSession(vaadinRequest); assert VaadinSession.getCurrent() == session; session.lock(); try { ui = service.findUI(vaadinRequest); assert UI.getCurrent() == ui; if (ui != null && ui.getPushConnection() != null) { .getPushConnection()).getResource(); } finally { try { session.unlock(); } catch (Exception e) { getLogger().log(Level.WARNING,
getLogger().warning( "A VaadinSession instance not associated to any service is getting unbound. " + "Session destroy events will not be fired and UIs in the session will not get detached. " + "This might happen if a session is deserialized but never used before it expires."); } else if (VaadinService.getCurrentRequest() != null && getCurrent() == this) { assert hasLock(); if (getAttribute( VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE) == Boolean.TRUE) { return; if (getState() == State.OPEN) { close();
@Override public Object remove(String name) { VaadinSession session = VaadinSession.getCurrent(); if (session == null || !session.hasLock()) { throw new IllegalStateException("Unable to use VaadinSessionScope from non-Vaadin thread"); } Object bean = session.getAttribute(name); session.setAttribute(name, null); return bean; }
public Locale getLocale() { return VaadinSession.getCurrent().getLocale(); }
@Override protected void init(VaadinRequest request) { initLogging(); // store the webservice URL property explicitly in the session in order to // access it from the "external" servlets getSession().getSession().setAttribute(WEBSERVICEURL_KEY, getSession().getAttribute(Helper.KEY_WEB_SERVICE_URL)); getSession().setAttribute(CONTEXT_PATH, request.getContextPath()); alreadyAddedCSS.clear(); initPlugins(); checkIfRemoteLoggedIn(request); getSession().addRequestHandler(new RemoteUserRequestHandler()); }
/** * Create a VaadinSession * @param locale Client locale * @return VaadinSession instance * @throws Exception Failed to create session */ protected VaadinSession createVaadinSession(Locale locale) throws Exception { WrappedSession wrappedSession = mock(WrappedSession.class); VaadinServletService vaadinService = mock(VaadinServletService.class); when(vaadinService.getDeploymentConfiguration()) .thenReturn(new DefaultDeploymentConfiguration(VaadinServletService.class, getDeploymentProperties())); VaadinSession session = mock(VaadinSession.class); when(session.getState()).thenReturn(VaadinSession.State.OPEN); when(session.getSession()).thenReturn(wrappedSession); when(session.getService()).thenReturn(vaadinService); when(session.getSession().getId()).thenReturn(TEST_SESSION_ID); when(session.hasLock()).thenReturn(true); when(session.getLocale()).thenReturn(locale != null ? locale : Locale.US); return session; }
SessionAwareBeanStore(VaadinSession session) { super("Session:" + session.getSession().getId()); this.session = session; this.session.getService().addSessionDestroyListener(this); this.session.getService().addServiceDestroyListener(this); this.session.setAttribute(BeanStore.class, this); }
protected void setSessionInternal(ClientUserSession userSession) { VaadinSession.getCurrent().setAttribute(UserSession.class, userSession); if (userSession != null) { AppContext.setSecurityContext(new SecurityContext(userSession)); } else { AppContext.setSecurityContext(null); } }
protected boolean isTryLoginOnStart() { Object attribute = VaadinSession.getCurrent().getAttribute(LOGIN_ON_START_ATTRIBUTE); if (attribute != null) { return (Boolean) attribute; } return true; }
private static WrappedSession getSession() { VaadinSession vaadinSession = VaadinSession.getCurrent(); if (vaadinSession != null) { return vaadinSession.getSession(); } else { return null; } }
private UI getBrowserDetailsUI(VaadinRequest request, VaadinSession session) { VaadinService vaadinService = request.getService(); List<UIProvider> uiProviders = session.getUIProviders(); UI retainedUI = session.getUIByEmbedId(embedId); if (retainedUI != null) { if (vaadinService.preserveUIOnRefresh(provider, Integer uiId = Integer.valueOf(session.getNextUIid()); if (ui.getSession() != session) { ui.setSession(session); pushMode = session.getService().getDeploymentConfiguration() .getPushMode(); ui.getPushConfiguration().setPushMode(pushMode); initException = e; session.addUI(ui); if (initException != null) { ui.getSession().getCommunicationManager() .handleConnectorRelatedException(ui, initException);
/** * Called after the framework has handled a request and the response has * been written. * * @param request * The request object * @param response * The response object * @param session * The session which was used during the request or null if the * request did not use a session */ public void requestEnd(VaadinRequest request, VaadinResponse response, VaadinSession session) { if (session != null) { assert VaadinSession.getCurrent() == session; session.lock(); try { cleanupSession(session); final long duration = (System.nanoTime() - (Long) request .getAttribute(REQUEST_START_TIME_ATTRIBUTE)) / 1000000; session.setLastRequestDuration(duration); } finally { session.unlock(); } } CurrentInstance.clearAll(); }