/** * Called by the server (via the <tt>service</tt> method) to allow a servlet to handle a GET request by supplying * a response * * @param httpServletRequest * - object that contains the request the client has made of the servlet * @param httpServletResponse * - object that contains the response the servlet sends to the client * * @throws IOException * - if an input or output error is detected when the servlet handles the GET request * @throws ServletException * - if the request for the GET could not be handled */ @Override protected void doGet(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws ServletException, IOException { pollForMessages(sessionProvider.createOrGetSession(httpServletRequest.getSession(true), getClientId(httpServletRequest)), httpServletRequest, httpServletResponse, true); }
@Override public void setSessionProvider(SessionProvider<S> sessionProvider) { if (this.sessionProvider != null) { throw new IllegalStateException("cannot set session provider more than once."); } sessionProvider.init(config); this.sessionProvider = sessionProvider; }
/** * Called by the server (via the <tt>service</tt> method) to allow a servlet to handle a GET request by supplying * a response * * @param httpServletRequest * - object that contains the request the client has made of the servlet * @param httpServletResponse * - object that contains the response the servlet sends to the client * * @throws IOException * - if an input or output error is detected when the servlet handles the GET request * @throws ServletException * - if the request for the GET could not be handled */ @Override protected void doGet(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws ServletException { pollForMessages(sessionProvider.createOrGetSession(httpServletRequest.getSession(true), getClientId(httpServletRequest)), httpServletRequest, httpServletResponse, isLongPollingEnabled(), isSSERequest(httpServletRequest)); }
@Override public void setSessionProvider(SessionProvider<S> sessionProvider) { if (this.sessionProvider != null) { throw new IllegalStateException("cannot set session provider more than once."); } sessionProvider.init(config); this.sessionProvider = sessionProvider; }
final QueueSession session = sessionProvider.createOrGetSession(httpServletRequest.getSession(true), getClientId(httpServletRequest));
protected void doPost(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws ServletException { final QueueSession session = sessionProvider.createOrGetSession(httpServletRequest.getSession(true), getClientId(httpServletRequest));
@Override protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException { final QueueSession session = sessionProvider.createOrGetSession(request.getSession(), getClientId(request)); session.setAttribute("NoSSE", Boolean.TRUE);
@Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException { final QueueSession session = sessionProvider.createOrGetSession(request.getSession(), getClientId(request)); session.setAttribute("NoSSE", Boolean.TRUE);
protected String getSessionId(final HttpServletRequest request, final SessionProvider sessionProvider) { final HttpSession session = request.getSession(true); final String clientId = getClientId(request); final QueueSession queueSession = sessionProvider.createOrGetSession(session, clientId); return queueSession.getSessionId(); }
protected String getSessionId(final HttpServletRequest request, final SessionProvider sessionProvider) { final HttpSession session = request.getSession(true); final String clientId = getClientId(request); final QueueSession queueSession = sessionProvider.createOrGetSession(session, clientId); return queueSession.getSessionId(); }
/** * Called by the server (via the <tt>service</tt> method) to allow a servlet to handle a GET request by supplying * a response * * @param httpServletRequest * - object that contains the request the client has made of the servlet * @param httpServletResponse * - object that contains the response the servlet sends to the client * * @throws IOException * - if an input or output error is detected when the servlet handles the GET request * @throws ServletException * - if the request for the GET could not be handled */ @Override protected void doGet(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws ServletException, IOException { pollForMessages(sessionProvider.createOrGetSession(httpServletRequest.getSession(true), getClientId(httpServletRequest)), httpServletRequest, httpServletResponse, true); }
/** * Called by the server (via the <tt>service</tt> method) to allow a servlet to handle a GET request by supplying * a response * * @param httpServletRequest * - object that contains the request the client has made of the servlet * @param httpServletResponse * - object that contains the response the servlet sends to the client * * @throws IOException * - if an input or output error is detected when the servlet handles the GET request * @throws ServletException * - if the request for the GET could not be handled */ @Override protected void doGet(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws ServletException { pollForMessages(sessionProvider.createOrGetSession(httpServletRequest.getSession(true), getClientId(httpServletRequest)), httpServletRequest, httpServletResponse, isLongPollingEnabled(), isSSERequest(httpServletRequest)); }
@Test public void testGetSessionId() throws Exception { final String clientId = "1"; final String sessionId = "2"; when(request.getSession(eq(true))).thenReturn(httpSession); when(request.getParameter(eq("clientId"))).thenReturn(clientId); when(provider.createOrGetSession(httpSession, clientId)).thenReturn(queueSession); when(queueSession.getSessionId()).thenReturn(sessionId); assertEquals(sessionId, abstractFileServlet().getSessionId(request, provider)); }
@Test public void testGetSessionIdWhenClientIdIsMissing() throws Exception { final String clientId = null; final String sessionId = "InvalidSessionId"; when(request.getSession(eq(true))).thenReturn(httpSession); when(request.getParameter(eq("clientId"))).thenReturn(clientId); when(provider.createOrGetSession(httpSession, "0")).thenReturn(queueSession); when(queueSession.getSessionId()).thenReturn(sessionId); assertEquals(sessionId, abstractFileServlet().getSessionId(request, provider)); }
@Test public void testGetSessionIdWhenClientIdIsMissing() throws Exception { final String clientId = null; final String sessionId = "InvalidSessionId"; when(request.getSession(eq(true))).thenReturn(httpSession); when(request.getParameter(eq("clientId"))).thenReturn(clientId); when(provider.createOrGetSession(httpSession, "0")).thenReturn(queueSession); when(queueSession.getSessionId()).thenReturn(sessionId); assertEquals(sessionId, abstractFileServlet().getSessionId(request, provider)); }
@Test public void testGetSessionId() throws Exception { final String clientId = "1"; final String sessionId = "2"; when(request.getSession(eq(true))).thenReturn(httpSession); when(request.getParameter(eq("clientId"))).thenReturn(clientId); when(provider.createOrGetSession(httpSession, clientId)).thenReturn(queueSession); when(queueSession.getSessionId()).thenReturn(sessionId); assertEquals(sessionId, abstractFileServlet().getSessionId(request, provider)); }
@Test public void testGetSessionIdWhenClientIdIsMissing() throws Exception { final String clientId = null; final String sessionId = "InvalidSessionId"; when(request.getSession(eq(true))).thenReturn(httpSession); when(request.getParameter(eq("clientId"))).thenReturn(clientId); when(provider.createOrGetSession(httpSession, "0")).thenReturn(queueSession); when(queueSession.getSessionId()).thenReturn(sessionId); assertEquals(sessionId, abstractFileServlet().getSessionId(request, provider)); }
@Test public void testGetSessionId() throws Exception { final String clientId = "1"; final String sessionId = "2"; when(request.getSession(eq(true))).thenReturn(httpSession); when(request.getParameter(eq("clientId"))).thenReturn(clientId); when(provider.createOrGetSession(httpSession, clientId)).thenReturn(queueSession); when(queueSession.getSessionId()).thenReturn(sessionId); assertEquals(sessionId, abstractFileServlet().getSessionId(request, provider)); }
final QueueSession session = sessionProvider.createOrGetSession(httpServletRequest.getSession(true), getClientId(httpServletRequest));
@Override protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException { final QueueSession session = sessionProvider.createOrGetSession(request.getSession(), getClientId(request)); session.setAttribute("NoSSE", Boolean.TRUE);