Examples of Continuation


Examples of org.eclipse.jetty.continuation.Continuation

        body = boshHandler.addAttribute(body, "condition", condition);
        BoshResponse boshResponse = getBoshResponse(body, null);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("BOSH writing response: {}", new String(boshResponse.getContent()));
        }
        Continuation continuation = ContinuationSupport.getContinuation(req.getHttpServletRequest());
        continuation.setAttribute("response", boshResponse);
        continuation.resume();
        close();
    }
View Full Code Here

Examples of org.eclipse.jetty.continuation.Continuation

            Stanza body = boshHandler.getTerminateResponse();
            BoshResponse boshResponse = getBoshResponse(body, null);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("BOSH writing response: {}", new String(boshResponse.getContent()));
            }
            Continuation continuation = ContinuationSupport.getContinuation(req.getHttpServletRequest());
            continuation.setAttribute("response", boshResponse);
            continuation.resume();
        }
       
        serverRuntimeContext.getResourceRegistry().unbindSession(this);
        sessionStateHolder.setState(SessionState.CLOSED);
       
View Full Code Here

Examples of org.eclipse.jetty.continuation.Continuation

     */
    public void insertRequest(BoshRequest br) {
        // reset the inactivity
        currentInactivity = inactivity;
       
        Continuation continuation = ContinuationSupport.getContinuation(br.getHttpServletRequest());
        addContinuationExpirationListener(continuation);
        continuation.setTimeout(wait * 1000);
        continuation.setAttribute("request", br);
        continuation.suspend();
       
        if (highestReadRid != null && highestReadRid + requests < br.getRid()) {
            LOGGER.warn("BOSH received RID greater than the permitted window of concurrent requests");
            error(br, "item-not-found");
            return;
View Full Code Here

Examples of org.eclipse.jetty.continuation.Continuation

    private void resendResponse(BoshRequest br) {
        BoshResponse boshResponse = sentResponses.get(br.getRid());
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("BOSH writing response: {}", new String(boshResponse.getContent()));
        }
        Continuation continuation = ContinuationSupport.getContinuation(br.getHttpServletRequest());
        continuation.setAttribute("response", boshResponse);
        continuation.resume();
        latestWriteTimestamp = System.currentTimeMillis();
    }
View Full Code Here

Examples of org.eclipse.jetty.continuation.Continuation

        // test session creation
        HttpServletRequest httpServletRequest = mocksControl.createMock(HttpServletRequest.class);
        expect(serverRuntimeContext.getNextSessionId()).andReturn("200");
        expect(serverRuntimeContext.getServerEnitity()).andReturn(new EntityImpl(null, "vysper.org", null));
        expect(serverRuntimeContext.getDefaultXMLLang()).andReturn("en");
        Continuation continuation = mocksControl.createMock(Continuation.class);
        expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
        expectLastCall().atLeastOnce();
        continuation.setTimeout(anyLong());
        Capture<BoshRequest> br = new Capture<BoshRequest>();
        continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br));
        continuation.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
        continuation.suspend();

        ServerFeatures serverFeatures = mocksControl.createMock(ServerFeatures.class);
        expect(serverRuntimeContext.getServerFeatures()).andReturn(serverFeatures);
        expect(serverFeatures.getAuthenticationMethods()).andReturn(Collections.<SASLMechanism> emptyList());

        Capture<BoshResponse> captured = new Capture<BoshResponse>();
        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(captured));
        continuation.resume();
        mocksControl.replay();

        Stanza boshRequest = createSessionRequest();
        boshHandler.process(httpServletRequest, boshRequest);
        mocksControl.verify();
       
        assertEquals(httpServletRequest, br.getValue().getHttpServletRequest());
        assertEquals(boshRequest, br.getValue().getBody());

        Stanza response = new XMLUtil(new String(captured.getValue().getContent())).parse();
        assertNotNull(response);
        assertEquals("body", response.getName());
        assertEquals(NamespaceURIs.XEP0124_BOSH, response.getNamespaceURI());
        assertEquals("200", response.getAttributeValue("sid"));
        assertEquals("vysper.org", response.getAttributeValue("from"));
        assertEquals("60", response.getAttributeValue("wait"));
        assertEquals("1", response.getAttributeValue("hold"));
        assertEquals("1.9", response.getAttributeValue("ver"));
        assertEquals(1, response.getInnerElements().size());
        XMLElement streamFeatures = response.getInnerElements().get(0);
        assertEquals("features", streamFeatures.getName());
        assertEquals(NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS, streamFeatures.getNamespaceURI());
        assertEquals(1, streamFeatures.getInnerElements().size());
        XMLElement saslMechanisms = streamFeatures.getInnerElements().get(0);
        assertEquals("mechanisms", saslMechanisms.getName());
        assertEquals(NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL, saslMechanisms.getNamespaceURI());

        // test session retrieval, retrieves the session above identified by sid=200
        mocksControl.reset();
        expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
        expectLastCall().atLeastOnce();
        continuation.setTimeout(anyLong());
        continuation.suspend();
        continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br));
        continuation.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
        StanzaProcessor stanzaProcessor = mocksControl.createMock(StanzaProcessor.class);
        expect(serverRuntimeContext.getStanzaProcessor()).andReturn(stanzaProcessor);
        Capture<Stanza> stanzaCaptured = new Capture<Stanza>();
        stanzaProcessor.processStanza(eq(serverRuntimeContext), EasyMock.<SessionContext> anyObject(),
                EasyMock.<Stanza> capture(stanzaCaptured), EasyMock.<SessionStateHolder> anyObject());
View Full Code Here

Examples of org.eclipse.jetty.continuation.Continuation

    public void tearDown() throws Exception {
    }

    @Test
    public void testWrite0() {
        Continuation continuation = mocksControl.createMock(Continuation.class);
        HttpServletRequest httpServletRequest = mocksControl.createMock(HttpServletRequest.class);
        expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
        expectLastCall().atLeastOnce();
        continuation.setTimeout(anyLong());
        continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> notNull());
        continuation.suspend();
        continuation.resume();
        continuation.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
        Capture<BoshResponse> captured = new Capture<BoshResponse>();
        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(captured));
        mocksControl.replay();

        BoshBackedSessionContext boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, serverRuntimeContext);
        Stanza body = new StanzaBuilder("body", NamespaceURIs.XEP0124_BOSH).build();
        boshBackedSessionContext.insertRequest(new BoshRequest(httpServletRequest, body, 1L));
View Full Code Here

Examples of org.eclipse.jetty.continuation.Continuation

    public void testRequestExpired() {
        Stanza body = new StanzaBuilder("body", NamespaceURIs.XEP0124_BOSH).build();

        // addRequest
        HttpServletRequest httpServletRequest = mocksControl.createMock(HttpServletRequest.class);
        Continuation continuation = mocksControl.createMock(Continuation.class);
        expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
        expectLastCall().atLeastOnce();
        continuation.setTimeout(anyLong());
        continuation.suspend();
        continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> notNull());

        Capture<ContinuationListener> listenerCaptured = new Capture<ContinuationListener>();
        continuation.addContinuationListener(EasyMock.<ContinuationListener> capture(listenerCaptured));
       
        BoshRequest br = new BoshRequest(httpServletRequest, body, 1L);

        // requestExpired
        expect(continuation.getAttribute("request")).andReturn(br);
        Capture<BoshResponse> responseCaptured = new Capture<BoshResponse>();
        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(responseCaptured));

        expect(boshHandler.getEmptyResponse()).andReturn(body);
        expectLastCall().atLeastOnce();

        // write0
        continuation.resume();

        mocksControl.replay();
        BoshBackedSessionContext boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, serverRuntimeContext);
       
        boshBackedSessionContext.insertRequest(br);
View Full Code Here

Examples of org.eclipse.jetty.continuation.Continuation

    @Test
    public void testAddRequest() {
        // addRequest
        HttpServletRequest httpServletRequest1 = mocksControl.createMock(HttpServletRequest.class);
        HttpServletRequest httpServletRequest2 = mocksControl.createMock(HttpServletRequest.class);
        Continuation continuation1 = mocksControl.createMock(Continuation.class);
        Continuation continuation2 = mocksControl.createMock(Continuation.class);
        expect(httpServletRequest1.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation1);
        expectLastCall().atLeastOnce();
        expect(httpServletRequest2.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation2);
        expectLastCall().atLeastOnce();
        continuation1.setTimeout(anyLong());
        continuation1.suspend();
        Capture<BoshRequest> br1 = new Capture<BoshRequest>();
        continuation1.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br1));
        continuation2.setTimeout(anyLong());
        continuation2.suspend();
        Capture<BoshRequest> br2 = new Capture<BoshRequest>();
        continuation2.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br2));
        continuation1.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
        continuation2.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
       
        Stanza body = new StanzaBuilder("body", NamespaceURIs.XEP0124_BOSH).build();
        expect(boshHandler.addAttribute(eq(body), eq("ack"), Long.toString(EasyMock.anyLong()))).andReturn(body);

        // write0
View Full Code Here

Examples of org.jruby.RubyContinuation.Continuation

     * @param tag The interned string to search for
     * @return The continuation associated with this tag
     */
    public Continuation getActiveCatch(Object tag) {
        for (int i = catchIndex; i >= 0; i--) {
            Continuation c = catchStack[i];
            if (runtime.is1_9()) {
                if (c.tag == tag) return c;
            } else {
                if (c.tag.equals(tag)) return c;
            }
View Full Code Here

Examples of org.mortbay.util.ajax.Continuation

        
           // handle the time request
           if (req.getRequestURI().endsWith("/time")) {
                            
              // get the jetty continuation
              Continuation cc = ContinuationSupport.getContinuation(req, null);
           
              // set the header
              resp.setContentType("text/html");
                                
              // write time periodically
              while (true) {
                 cc.suspend(1000); // suspend the response
                 String script = "<script>\r\n" +
                                 "  parent.printTime(\"" + new Date() + "\");\r\n" +
                                 "</script>";
                 resp.getWriter().println(script);
                 resp.getWriter().flush();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.