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]); } }
/** Cleans up the info carried from onPiggyback to the current thread. * <p>Note: {@link #carryOver} and {@link #cleanup} must be * called in the same thread. */ public void cleanup() { ((ExecutionCtrl) _exec).onDeactivate(); ExecutionsCtrl.setCurrent(null); if (_locale != null) Locales.setThreadLocal(null); if (_timeZone != null) TimeZones.setThreadLocal(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; }
/** Carry over the info stored in the constructor to * the current thread. */ public void carryOver() { ExecutionsCtrl.setCurrent(_exec); final ExecutionCtrl execCtrl = (ExecutionCtrl) _exec; execCtrl.onActivate(); if (Locales.getThreadLocal() == null) Locales.setThreadLocal(_locale); else _locale = null; if (TimeZones.getThreadLocal() == null) TimeZones.setThreadLocal(_timeZone); else _timeZone = null; final Page page = _exec.getDesktop().getFirstPage(); if (page != null) execCtrl.setCurrentPage(page); }
TimeZones.setThreadLocal(_timeZone); TimeZones.setThreadLocal(_timeZone = null);