Package org.eclipse.jetty.continuation

Examples of org.eclipse.jetty.continuation.Continuation.suspend()


                // case where we are processing this request for the first time (suspend has not been called)
                final JettyHttpMessageReceiver receiver = (JettyHttpMessageReceiver) getReceiverForURI(request);
                final JettyHttpMessageReceiver.ContinuationsResponseHandler continuationsResponseHandler = receiver.processMessageAsync(request, response, continuation);
                continuation.setAttribute(RESPONSE_HANDLER_KEY, continuationsResponseHandler);
                // suspend indefinitely
                continuation.suspend();
            }
            else
            {
                // case where we are processing this request for the second time.
                if (continuation.isResumed())
View Full Code Here


                    respond(request, response);
                    Continuation continuation = ContinuationSupport.getContinuation(request);
                    // Infinite timeout because the continuation is never resumed,
                    // but only completed on close
                    continuation.setTimeout(0L);
                    continuation.suspend(response);
                    EventSourceEmitter emitter = new EventSourceEmitter(eventSource, continuation);
                    emitter.scheduleHeartBeat();
                    open(eventSource, emitter);
                }
                return;
View Full Code Here

            }
           
            log.trace("Suspending continuation of exchangeId: {}", exchange.getExchangeId());
            continuation.setAttribute(EXCHANGE_ATTRIBUTE_ID, exchange.getExchangeId());
            // must suspend before we process the exchange
            continuation.suspend();

            ClassLoader oldTccl = overrideTccl(exchange);
           
            log.trace("Processing request for exchangeId: {}", exchange.getExchangeId());
            // use the asynchronous API to process the exchange
View Full Code Here

    log.info(toString());
  }

  private void executeContinuation(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) {
    final Continuation continuation = ContinuationSupport.getContinuation(baseRequest);
    continuation.suspend();
    if (continuationTimeoutMillis > 0) {
      continuation.setTimeout(continuationTimeoutMillis);
    }
    executor.execute(new Runnable() {
View Full Code Here

    public void process(Request request, HttpServletResponse response) {
        Client client = null;
        boolean adminMode = false;

        Continuation continuation = ContinuationSupport.getContinuation(request);
        continuation.suspend(response);
        String jsonp = null;
        try {
            // first check for a catalog update and purge the cached connections
            // if one has happened since we were here last
            if (m_shouldUpdateCatalog.compareAndSet(true, false))
View Full Code Here

        return new AbstractHandler() {
            public void handle(String s, Request request, HttpServletRequest req, final HttpServletResponse resp) throws IOException, ServletException {
                resp.setContentType("text/plain;charset=utf-8");
                resp.setStatus(200);
                final Continuation continuation = ContinuationSupport.getContinuation(req);
                continuation.suspend();
                final PrintWriter writer = resp.getWriter();
                executorService.submit(new Runnable() {
                    public void run() {
                        try {
                            Thread.sleep(100);
View Full Code Here

    private class SlowHandler extends AbstractHandler {
        public void handle(String target, Request baseRequest, HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
            response.setStatus(HttpServletResponse.SC_OK);
            final Continuation continuation = ContinuationSupport.getContinuation(request);
            continuation.suspend();
            new Thread(new Runnable() {
                public void run() {
                    try {
                        Thread.sleep(1500);
                        response.getOutputStream().print(MSG);
View Full Code Here

    private class ExpectExceptionHandler extends AbstractHandler {
        public void handle(String target, Request baseRequest, HttpServletRequest request, final HttpServletResponse response)
                throws IOException, ServletException {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
            final Continuation continuation = ContinuationSupport.getContinuation(request);
            continuation.suspend();
            new Thread(new Runnable() {
                public void run() {
                    try {
                        response.getOutputStream().print(MSG);
                        response.getOutputStream().flush();
View Full Code Here

    private class SlowHandler extends AbstractHandler {
        public void handle(String target, Request baseRequest, HttpServletRequest request, final HttpServletResponse response)
                throws IOException, ServletException {
            response.setStatus(HttpServletResponse.SC_OK);
            final Continuation continuation = ContinuationSupport.getContinuation(request);
            continuation.suspend();
            new Thread(new Runnable() {
                public void run() {
                    try {
                        Thread.sleep(SLEEPTIME_MS);
                        response.getOutputStream().print(MSG);
View Full Code Here

                exchange.setIn(new HttpMessage(exchange, request, response));

                if (log.isTraceEnabled()) {
                    log.trace("Suspending continuation of exchangeId: " + exchange.getExchangeId());
                }
                continuation.suspend();

                // use the asynchronous API to process the exchange
                consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean doneSync) {
                        if (log.isTraceEnabled()) {
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.