* Creates the session context at the session start.
* @param session http session object
*/
private void initSessionContext(HttpSession session)
{
SessionContext currentSessionContext;
if (session == null)
{
// no session -> create a dummy SessionContext
// this is handy if you create asynchronous tasks or
// batches which use a 'admin' user.
currentSessionContext = new SessionContext();
}
else
{
String sessionId = session.getId();
//Current context
currentSessionContext = sessionCtxManager.getSessionContextWithSessionId(sessionId);
//No current context
if (currentSessionContext == null)
{
currentSessionContext = new SessionContext();
sessionCtxManager.addNewSessionContext(sessionId, currentSessionContext);
}
}
//Activate
currentSessionContext.setActive(true);
//Set thread local
sessionContexts.set(currentSessionContext);
}