@Override public void sessionDestroyed(final Session session, final HttpServerExchange exchange, final SessionDestroyedReason reason) { if (reason == SessionDestroyedReason.TIMEOUT) { try { //we need to perform thread setup actions destroyedAction.call(exchange, session); } catch (Exception e) { throw new RuntimeException(e); } } else { doDestroy(session); } ServletRequestContext current = SecurityActions.currentServletRequestContext(); Session underlying = null; if (current != null && current.getSession() != null) { if (System.getSecurityManager() == null) { underlying = current.getSession().getSession(); } else { underlying = AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(current.getSession())); } } if (current != null && underlying == session) { current.setSession(null); } }
public static HttpSessionImpl forSession(final Session session, final ServletContext servletContext, final boolean newSession) { // forSession is called by privileged actions only so no need to do it again ServletRequestContext current = ServletRequestContext.current(); if (current == null) { return new HttpSessionImpl(session, servletContext, newSession, null); } else { HttpSessionImpl httpSession = current.getSession(); if (httpSession == null) { httpSession = new HttpSessionImpl(session, servletContext, newSession, current); current.setSession(httpSession); } else { if(httpSession.session != session) { //in some rare cases it may be that there are two different service contexts involved in the one request //in this case we just return a new session rather than using the thread local version httpSession = new HttpSessionImpl(session, servletContext, newSession, current); } } return httpSession; } }
public static HttpSession forConvergedSession(final Session session, final ServletContext servletContext, final boolean newSession, SessionManager manager) { // forSession is called by privileged actions only so no need to do it again ServletRequestContext current = ServletRequestContext.current(); if (current == null) { return new ConvergedHttpSessionFacade(HttpSessionImpl.forSession(session, servletContext, newSession), manager); } else { HttpSessionImpl httpSession = current.getSession(); if (httpSession == null) { httpSession = HttpSessionImpl.forSession(session, servletContext, newSession); current.setSession(httpSession); } else { if(httpSession.getSession() != session) { //in some rare cases it may be that there are two different service contexts involved in the one request //in this case we just return a new session rather than using the thread local version httpSession = HttpSessionImpl.forSession(session, servletContext, newSession); } } return new ConvergedHttpSessionFacade(httpSession, manager); } }
public static HttpSession forConvergedSession(final Session session, final ServletContext servletContext, final boolean newSession, SessionManager manager) { // forSession is called by privileged actions only so no need to do it again ServletRequestContext current = ServletRequestContext.current(); if (current == null) { return new ConvergedHttpSessionFacade(HttpSessionImpl.forSession(session, servletContext, newSession), manager); } else { HttpSessionImpl httpSession = current.getSession(); if (httpSession == null) { httpSession = HttpSessionImpl.forSession(session, servletContext, newSession); current.setSession(httpSession); } else { if(httpSession.getSession() != session) { //in some rare cases it may be that there are two different service contexts involved in the one request //in this case we just return a new session rather than using the thread local version httpSession = HttpSessionImpl.forSession(session, servletContext, newSession); } } return new ConvergedHttpSessionFacade(httpSession, manager); } }
servletRequestContext.setSession(null); servletRequestContext.setCurrentServletContext(this.servletContext); this.servletContext.invokeAction(servletRequestContext.getExchange(), new ThreadSetupHandler.Action<Void, Object>() { servletRequestContext.setSession(oldSession); servletRequestContext.setCurrentServletContext(oldServletContext);
servletRequestContext.setSession(null); servletRequestContext.setCurrentServletContext(this.servletContext); try { servletRequestContext.setSession(oldSession); servletRequestContext.setCurrentServletContext(oldServletContext);