// there could be multiple threads using a session.
final AuthenticatedWebSessionForIsis webSession = (AuthenticatedWebSessionForIsis) Session.get();
webSession.registerUseByThread();
IsisSession isisSession = sessionMap.get(webSession);
if (isisSession == null) {
isisSession = getSessionFactoryInstance().openSession(authSession);
// put into map prior to opening, so that subsequent calls to
// getSessionInstance() will find this new session.
sessionMap.put(webSession, isisSession);
isisSession.open();
}
return isisSession;
}