Package javax.servlet

Examples of javax.servlet.AsyncContext.addListener()


  public void index(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {
    if (req.isAsyncStarted()) {
      req.getAsyncContext().complete();
    } else if (req.isAsyncSupported()) {
      AsyncContext actx = req.startAsync();
      actx.addListener(this);
      resp.setContentType("text/plain");
      actx.setTimeout(3000);
      clients.add(actx);
      if (clientcount.incrementAndGet() == 1) {
        ticker.addTickListener(this);
View Full Code Here


    private void suspend(Action action, HttpServletRequest req, HttpServletResponse res)
            throws IOException, ServletException {

        if (!req.isAsyncStarted()) {
            AsyncContext asyncContext = req.startAsync();
            asyncContext.addListener(new CometListener());
            // Do nothing except setting the times out
            if (action.timeout != -1) {
                asyncContext.setTimeout(action.timeout);
            } else {
                // Jetty 8 does something really weird if you set it to
View Full Code Here

            throws IOException, ServletException {

        if (!req.isAsyncStarted()) {

            AsyncContext asyncContext = req.startAsync();
            asyncContext.addListener(new CometListener());
            // Do nothing except setting the times out
            if (action.timeout != -1) {
                asyncContext.setTimeout(action.timeout);
            } else {
                // Jetty 8 does something really weird if you set it to
View Full Code Here

        @Override
        protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            // step 1 - start async
            AsyncContext actx = req.startAsync();
            actx.setTimeout(Long.MAX_VALUE);
            actx.addListener(new AsyncListener() {

                @Override
                public void onTimeout(AsyncEvent event) throws IOException {
                    log.info("onTimeout");
View Full Code Here

        @Override
        protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            // step 1 - start async
            AsyncContext actx = req.startAsync();
            actx.setTimeout(Long.MAX_VALUE);
            actx.addListener(new AsyncListener() {

                @Override
                public void onTimeout(AsyncEvent event) throws IOException {
                    log.info("onTimeout");
View Full Code Here

      prepareSSE(asynResponse);
      prepareSSEContinue(asynResponse);
      asynResponse.getOutputStream().flush();
      writer = new OutputStreamWriteAdapter(asynResponse.getOutputStream());

      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

      final AsyncContext asyncContext = request.startAsync();
      asyncContext.setTimeout(60000);
      queue.setTimeout(65000);
      writer = new OutputStreamWriteAdapter(asyncContext.getResponse().getOutputStream());

      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

      final AsyncContext asyncContext = request.startAsync();
      asyncContext.setTimeout(getSSETimeout());
      queue.setTimeout(getSSETimeout() + 5000);

      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

    else {
      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

  public Object suspend(final CometServletResponseImpl response, CometSessionImpl session, HttpServletRequest request) throws IOException {
    assert Thread.holdsLock(response);
    assert session == null || !Thread.holdsLock(session);
    response.flush();
    AsyncContext asyncContext = request.startAsync();
    asyncContext.addListener(new AsyncListener() {
     
      @Override
      public void onStartAsync(AsyncEvent e) throws IOException {
      }
     
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.