Package javax.servlet

Examples of javax.servlet.AsyncListener


                if (timeout && !asyncListenerRegistrations.hasNext()) {
                    // FIXME: MUST do an ERROR dispatch to the original URI and MUST set the response code to 500
                }
                while (asyncListenerRegistrations.hasNext()) {
                    AsyncListenerRegistration asyncListenerRegistration = asyncListenerRegistrations.next();
                    AsyncListener asyncListener = asyncListenerRegistration.getListener();
                    try {
                        if (timeout) {
                            AsyncEvent asyncEvent = new AsyncEvent(asyncContext,
                                    asyncListenerRegistration.getRequest(), asyncListenerRegistration.getResponse());
                            asyncListener.onTimeout(asyncEvent);
                        } else if (error) {
                            Throwable t = (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);
                            AsyncEvent asyncEvent = new AsyncEvent(asyncContext,
                                    asyncListenerRegistration.getRequest(), asyncListenerRegistration.getResponse(), t);
                            asyncListener.onError(asyncEvent);
                        } else {
                            AsyncEvent asyncEvent = new AsyncEvent(asyncContext,
                                    asyncListenerRegistration.getRequest(), asyncListenerRegistration.getResponse());
                            asyncListener.onComplete(asyncEvent);
                        }
                    } catch (Throwable e) {
                        container.getLogger().error(sm.getString("standardWrapper.async.listenerError",
                                getContainer().getName()), e);
                        exception(request, response, e);
View Full Code Here


   
    final AsyncContext asyncContext = request.startAsync();
    asyncContext.setTimeout(60000);
    queue.setTimeout(65000);
   
    asyncContext.addListener(new AsyncListener() {
        @Override
        public void onComplete(final AsyncEvent event) throws IOException {
          clearActivationCallback(queue);
        }
View Full Code Here

            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Async Servlet</h1>");
            AsyncContext ac = request.startAsync();

            ac.addListener(new AsyncListener() {
                @Override
                public void onComplete(AsyncEvent event) throws IOException {
                    System.out.println("onComplete");
                }
View Full Code Here

    // Id

    final String id = UUID.randomUUID().toString();
    final AsyncContext ac = req.startAsync(req, resp);
    ac.setTimeout(30 * 60 * 1000);
    ac.addListener(new AsyncListener() {

      @Override
      public void onTimeout(AsyncEvent event) throws IOException {
        log("on timeout");
        asyncContexts.remove(id);
View Full Code Here

        this.optionsRequests = registry.timer(name(prefix, "options-requests"));
        this.traceRequests = registry.timer(name(prefix, "trace-requests"));
        this.connectRequests = registry.timer(name(prefix, "connect-requests"));
        this.otherRequests = registry.timer(name(prefix, "other-requests"));

        this.listener = new AsyncListener() {
            @Override
            public void onTimeout(AsyncEvent event) throws IOException {
                asyncTimeouts.mark();
            }
View Full Code Here

                return null;
            }
        });

        // 当timeout时中断异步线程,并结束请求
        asyncContext.addListener(new AsyncListener() {
            public void onComplete(AsyncEvent event) throws IOException {
            }

            public void onTimeout(AsyncEvent event) throws IOException {
                log.debug("Async task timed out.");
View Full Code Here

   
    final AsyncContext asyncContext = request.startAsync();
    asyncContext.setTimeout(60000);
    queue.setTimeout(65000);
   
    asyncContext.addListener(new AsyncListener() {
        @Override
        public void onComplete(final AsyncEvent event) throws IOException {
          synchronized (queue.getActivationLock()) {
            queue.setActivationCallback(null);
            asyncContext.complete();
View Full Code Here

      queue.poll(false, response.getOutputStream());
      return;
    }

    final AsyncContext asyncContext = request.startAsync();
    asyncContext.addListener(new AsyncListener() {
      @Override
      public void onTimeout(AsyncEvent event) throws IOException {
        poll(queue, asyncContext);
        asyncContext.complete();
      }
View Full Code Here

        this.traceRequests = metricRegistry.timer(name(prefix, "trace-requests"));
        this.connectRequests = metricRegistry.timer(name(prefix, "connect-requests"));
        this.moveRequests = metricRegistry.timer(name(prefix, "move-requests"));
        this.otherRequests = metricRegistry.timer(name(prefix, "other-requests"));

        this.listener = new AsyncListener() {
            @Override
            public void onTimeout(AsyncEvent event) throws IOException {
                asyncTimeouts.mark();
            }
View Full Code Here

        this.traceRequests = metricRegistry.timer(name(prefix, "trace-requests"));
        this.connectRequests = metricRegistry.timer(name(prefix, "connect-requests"));
        this.moveRequests = metricRegistry.timer(name(prefix, "move-requests"));
        this.otherRequests = metricRegistry.timer(name(prefix, "other-requests"));

        this.listener = new AsyncListener() {
            @Override
            public void onTimeout(AsyncEvent event) throws IOException {
                asyncTimeouts.mark();
            }
View Full Code Here

TOP

Related Classes of javax.servlet.AsyncListener

Copyright © 2018 www.massapicom. 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.