/** * Convenience method that creates a new GlobalVariables stack frame, initialized with the * provided UserSession (which may be the previous UserSession). * * @param userSession the UserSession to initialize the new frame with (may be null) * @param callable the code to run under a new set of GlobalVariables * @throws Exception */ public static <T> T doInNewGlobalVariables(UserSession userSession, Callable<T> callable) throws Exception { try { GlobalVariables vars = pushGlobalVariables(); if (userSession != null) { vars.userSession = userSession; } return callable.call(); } finally { popGlobalVariables(); } }
/** * sets the userSession object into the global variable for this thread * * @param userSession */ public static void setUserSession(UserSession userSession) { GlobalVariables vars = getCurrentGlobalVariables(); vars.userSession = userSession; }