/** Cleanup this process after processing the event by calling * {@link #process}. * * <p>Note: Don't call this method if the event process executes * in the same thread. */ public void cleanup() { ExecutionsCtrl.setCurrent(null); SessionsCtrl.setCurrent((Session) null); }
public static final void cleanup(ServletRequest request, Object old) { if (old != null) { request.removeAttribute(ATTR_SETUP); SessionsCtrl.setCurrent((Session) null); final Object[] op = (Object[]) old; TimeZones.setThreadLocal((TimeZone) op[1]); DateFormats.setLocalFormatInfo((DateFormatInfo) op[2]); Charsets.cleanup(request, op[0]); } }
/** 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); } }
/** Setup this processor before processing the event by calling * {@link #process}. * * <p>Note: it doesn't invoke {@link ExecutionCtrl#onActivate} */ public void setup() { SessionsCtrl.setCurrent(_desktop.getSession()); final Execution exec = _desktop.getExecution(); ExecutionsCtrl.setCurrent(exec); ((ExecutionCtrl) exec).setCurrentPage(getPage()); }
/** 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; }
SessionsCtrl.setCurrent(sess); try { response.setProperty("Pragma", "no-cache"); I18Ns.cleanup(httpreq, old); SessionsCtrl.requestExit(sess); SessionsCtrl.setCurrent((Session) null);
private static final Object setup(Object sess, ServletRequest request, ServletResponse response, String charset) { final Object[] old; if (request.getAttribute(ATTR_SETUP) != null) { //has been setup old = null; } else { final HttpSession hsess; if (sess instanceof Session) { final Session se = (Session) sess; //Invoke the request interceptors se.getWebApp().getConfiguration().invokeRequestInterceptors(se, request, response); hsess = (HttpSession) se.getNativeSession(); } else { hsess = (HttpSession) sess; } final Object ol = Charsets.setup(hsess, request, response, charset); //Charsets will handle PREFERRED_LOCALE //time zone final TimeZone tz = getTimeZone(hsess); final Object otz = TimeZones.setThreadLocal(tz); //date format info final DateFormatInfo dfinfo = getDateFormatInfo(hsess); final Object odi = DateFormats.setLocalFormatInfo(dfinfo); request.setAttribute(ATTR_SETUP, Boolean.TRUE); //mark as setup old = new Object[] { ol, otz, odi }; } if (sess instanceof Session) SessionsCtrl.setCurrent((Session) sess); return old; }
if (hsess == null) { oldsess = SessionsCtrl.getRawCurrent(); SessionsCtrl.setCurrent(new SessionResolverImpl(ctx, request)); if (sess == null) { oldsess = SessionsCtrl.getRawCurrent(); SessionsCtrl.setCurrent(new SessionResolverImpl(ctx, request));
return; SessionsCtrl.setCurrent(sess); try { SessionsCtrl.setCurrent((Session) null);
SessionsCtrl.setCurrent(sess); Object old = I18Ns.setup(sess, request, response, "UTF-8"); try { SessionsCtrl.setCurrent((Session)null); RequestContexts.pop(); I18Ns.cleanup(request, old);
response = init(new MockHttpServletResponse()); session = SessionsCtrl.newSession(webApp, init(new MockHttpSession(servletContext, "mock")), request); SessionsCtrl.setCurrent(session);