/** Used by the deriving class to pre-process a session before writing * the session */ protected void sessionWillPassivate() { final Object old = SessionsCtrl.getRawCurrent(); //shall be null; just in case SessionsCtrl.setCurrent(this); try { ((WebAppCtrl) _wapp).sessionWillPassivate(this); for (Enumeration<String> en = getAttrNames(); en.hasMoreElements();) { final String nm = en.nextElement(); willPassivate(getAttribute(nm)); } } finally { SessionsCtrl.setRawCurrent(old); } }
/** Used by the deriving class to post-process a session after * it is read back. * * <p>Application shall not call this method directly. */ protected void sessionDidActivate(HttpSession hsess) { //Note: in Tomcat, servlet is activated later, so we have to //add listener to WebManager instead of process now final Object old = SessionsCtrl.getRawCurrent(); //shall be null; just in case SessionsCtrl.setCurrent(this); try { _navsess = hsess; WebManager.addActivationListener(hsess.getServletContext(), //FUTURE: getServletContext only in Servlet 2.3 or later new WebManagerActivationListener() { public void didActivate(WebManager webman) { _wapp = webman.getWebApp(); ((WebAppCtrl) _wapp).sessionDidActivate(SimpleSession.this); } }); for (Enumeration<String> en = getAttrNames(); en.hasMoreElements();) { final String nm = en.nextElement(); didActivate(getAttribute(nm)); } } finally { SessionsCtrl.setRawCurrent(old); } }
/** Called before serving a HTTP request. * @return the recycled desktop, or null if no recycled desktop is matched * for this request. */ public static Desktop beforeService(DesktopRecycle dtrc, ServletContext ctx, Session sess, HttpServletRequest request, HttpServletResponse response, String path) { if (dtrc != null) { final Execution olde = Executions.getCurrent(); final Object olds = SessionsCtrl.getRawCurrent(); final Execution exec = new TemporaryExecution(ctx, request, response, null); SessionsCtrl.setCurrent(sess); ExecutionsCtrl.setCurrent(exec); try { return dtrc.beforeService(exec, getURI(path, request.getQueryString())); } catch (Throwable ex) { log.error("", ex); } finally { ExecutionsCtrl.setCurrent(olde); SessionsCtrl.setRawCurrent(olds); } } return null; }
else { Charsets.cleanup(request, old); SessionsCtrl.setRawCurrent(oldsess); else { Charsets.cleanup(request, old); SessionsCtrl.setRawCurrent(oldsess);