use of org.eclipse.scout.rt.ui.html.ISessionStore in project scout.rt by eclipse.
the class JsonMessageRequestHandler method createUiSession.
protected IUiSession createUiSession(HttpServletRequest req, HttpServletResponse resp, JsonStartupRequest jsonStartupReq) throws ServletException, IOException {
HttpSession httpSession = req.getSession();
ISessionStore sessionStore = m_httpSessionHelper.getSessionStore(httpSession);
final long startNanos = System.nanoTime();
if (LOG.isDebugEnabled()) {
LOG.debug("JSON request started");
}
LOG.debug("Creating new UI session....");
IUiSession uiSession = BEANS.get(IUiSession.class);
uiSession.init(req, resp, jsonStartupReq);
sessionStore.registerUiSession(uiSession);
LOG.info("Created new UI session with ID {} in {} ms [maxIdleTime={}s, httpSession.maxInactiveInterval={}s]", uiSession.getUiSessionId(), StringUtility.formatNanos(System.nanoTime() - startNanos), m_maxUserIdleTime, req.getSession().getMaxInactiveInterval());
return uiSession;
}
use of org.eclipse.scout.rt.ui.html.ISessionStore in project scout.rt by eclipse.
the class JsonTestUtility method createAndInitializeUiSession.
public static IUiSession createAndInitializeUiSession() {
String clientSessionId = "testClientSession123";
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
final HttpSession httpSession = Mockito.mock(HttpSession.class);
final Object sessionMutex = new Object();
Mockito.when(request.getLocale()).thenReturn(new Locale("de_CH"));
Mockito.when(request.getHeader("User-Agent")).thenReturn("dummy");
Mockito.when(request.getSession()).thenReturn(httpSession);
Mockito.when(request.getSession(false)).thenReturn(httpSession);
Mockito.when(httpSession.getAttribute(HttpSessionMutex.SESSION_MUTEX_ATTRIBUTE_NAME)).thenReturn(sessionMutex);
final ISessionStore sessionStore = BEANS.get(HttpSessionHelper.class).getSessionStore(httpSession);
Mockito.when(httpSession.getAttribute(HttpSessionHelper.SESSION_STORE_ATTRIBUTE_NAME)).thenReturn(sessionStore);
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
((HttpSessionBindingListener) sessionStore).valueUnbound(null);
return null;
}
}).when(httpSession).invalidate();
JSONObject jsonReqObj = new JSONObject();
jsonReqObj.put(JsonStartupRequest.PROP_CLIENT_SESSION_ID, clientSessionId);
jsonReqObj.put("startup", true);
JsonStartupRequest jsonStartupRequest = new JsonStartupRequest(new JsonRequest(jsonReqObj));
IUiSession uiSession = new TestEnvironmentUiSession();
uiSession.init(request, response, jsonStartupRequest);
return uiSession;
}
use of org.eclipse.scout.rt.ui.html.ISessionStore in project scout.rt by eclipse.
the class UnloadRequestHandler method handleUnloadRequest.
protected void handleUnloadRequest(HttpServletRequest req, HttpServletResponse resp, String uiSessionId) {
LOG.info("Unloading UI session with ID {} (requested by UI)", uiSessionId);
final HttpSession httpSession = req.getSession();
final ISessionStore sessionStore = BEANS.get(HttpSessionHelper.class).getSessionStore(httpSession);
IUiSession uiSession = sessionStore.getUiSession(uiSessionId);
if (uiSession != null) {
final ReentrantLock uiSessionLock = uiSession.uiSessionLock();
uiSessionLock.lock();
try {
uiSession.dispose();
} finally {
uiSessionLock.unlock();
}
}
}
Aggregations