Examples of HttpEvent


Examples of org.jboss.servlet.http.HttpEvent

     * @throws java.io.IOException
     * @throws javax.servlet.ServletException
     */
    public Action service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {

        HttpEvent event = (HttpEvent) req.getAttribute(HTTP_EVENT);

        // Comet is not enabled.
        if (event == null) {
            throw unableToDetectComet;
        }

        Action action = null;
        // For now, we are just interested in HttpEvent.REA
        if (event.getType() == HttpEvent.EventType.BEGIN) {
            action = suspended(req, res);
            if (action.type == Action.TYPE.SUSPEND) {
                logger.debug("Suspending response: {}", res);

                // Do nothing except setting the times out
                try {
                    if (action.timeout != -1) {
                        event.setTimeout((int) action.timeout);
                    }
                    else {
                        event.setTimeout(Integer.MAX_VALUE);
                    }
                }
                catch (UnsupportedOperationException ex) {
                    // Swallow s Tomcat APR isn't supporting time out
                    // TODO: Must implement the same functionality using a Scheduler
                }
            }
            else if (action.type == Action.TYPE.RESUME) {
                logger.debug("Resuming response: {}", res);
                event.close();
            }
            else {
                event.close();
            }
        }
        else if (event.getType() == HttpEvent.EventType.READ) {
            // Not implemente
        } else if (event.getType() == HttpEvent.EventType.EOF) {
            logger.debug("Client closed connection: response: {}", res);

            if (!resumed.remove(event)) {
                logger.debug("Client closed connection: response: {}", res);
                action = cancelled(req, res);
            } else {
                logger.debug("Cancelling response: {}", res);
            }

            event.close();
        } else if (event.getType() == HttpEvent.EventType.ERROR) {
            event.close();
        }
        else if (event.getType() == HttpEvent.EventType.END) {
            if (!resumed.remove(event)) {
                logger.debug("Client closed connection response: {}", res);
                action = cancelled(req, res);
            }
            else {
                logger.debug("Cancelling response: {}", res);
            }
            event.close();
        }
        else if (event.getType() == HttpEvent.EventType.TIMEOUT) {
            logger.debug("Timing out {}", res);
            action = timedout(req, res);
            event.close();
        }
        return action;
    }
View Full Code Here

Examples of org.jboss.servlet.http.HttpEvent

    @Override
    public Action cancelled(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {

        Action action = super.cancelled(req, res);
        if (req.getAttribute(MAX_INACTIVE) != null && Long.class.cast(req.getAttribute(MAX_INACTIVE)) == -1) {
            HttpEvent event = (HttpEvent) req.getAttribute(HTTP_EVENT);
            if (event == null) {
                return action;
            }
            resumed.offer(event);
            event.close();
        }
        return action;
    }
View Full Code Here

Examples of org.jboss.servlet.http.HttpEvent

    @Override
    public void action(AtmosphereResourceImpl actionEvent) {
        super.action(actionEvent);
        if (actionEvent.action().type == Action.TYPE.RESUME && actionEvent.isInScope()) {
            try {
                HttpEvent event = (HttpEvent) actionEvent.getRequest().getAttribute(HTTP_EVENT);
                resumed.offer(event);
                // Resume without closing the underlying suspended connection.
                if (config.getInitParameter(AtmosphereServlet.RESUME_AND_KEEPALIVE) == null ||
                        config.getInitParameter(AtmosphereServlet.RESUME_AND_KEEPALIVE).equalsIgnoreCase("false")) {
                    event.close();
                }
            }
            catch (IOException ex) {
                logger.debug("", ex);
            }
View Full Code Here

Examples of org.jboss.servlet.http.HttpEvent

            CometEvent event = (CometEvent) req.getAttribute(TomcatCometSupport.COMET_EVENT);
            if (event != null) {
                event.close();
            }

            HttpEvent he = (HttpEvent) req.getAttribute(JBossWebCometSupport.HTTP_EVENT);
            if (he != null) {
                he.close();
            }
        }
        return action;
    }
View Full Code Here

Examples of org.jboss.servlet.http.HttpEvent

     * @throws javax.servlet.ServletException
     */
    public Action service(HttpServletRequest req, HttpServletResponse res)
            throws IOException, ServletException {

        HttpEvent event = (HttpEvent) req.getAttribute(HTTP_EVENT);

        // Comet is not enabled.
        if (event == null) {
            throw unableToDetectComet;
        }

        Action action = null;
        // For now, we are just interested in HttpEvent.REA
        if (event.getType() == HttpEvent.EventType.BEGIN) {
            action = suspended(req, res);
            if (action.type == Action.TYPE.SUSPEND) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("Suspending " + res);
                }

                // Do nothing except setting the times out
                try {
                    if (action.timeout != -1) {
                        event.setTimeout((int) action.timeout);
                    } else {
                        event.setTimeout(Integer.MAX_VALUE);
                    }
                } catch (UnsupportedOperationException ex) {
                    // Swallow s Tomcat APR isn't supporting time out
                    // TODO: Must implement the same functionality using a
                    // Scheduler
                }
            } else if (action.type == Action.TYPE.RESUME) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("Resuming " + res);
                }
                event.close();
            } else {
                event.close();
            }
        } else if (event.getType() == HttpEvent.EventType.READ) {
            // Not implemente
        } else if (event.getType() == HttpEvent.EventType.ERROR) {
            event.close();
        } else if (event.getType() == HttpEvent.EventType.END) {
            if (!resumed.remove(event)) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("Client closed connection " + res);
                }
                action = cancelled(req, res);
            } else {
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("Cancelling " + res);
                }
            }
            event.close();
        } else if (event.getType() == HttpEvent.EventType.TIMEOUT) {
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Timing out " + res);
            }
            action = timedout(req, res);
            event.close();
        }
        return action;
    }
View Full Code Here

Examples of org.jboss.servlet.http.HttpEvent

    public Action cancelled(HttpServletRequest req, HttpServletResponse res)
            throws IOException, ServletException {

        Action action =  super.cancelled(req,res);
        if (req.getAttribute(MAX_INACTIVE) != null && Long.class.cast(req.getAttribute(MAX_INACTIVE)) == -1) {
           HttpEvent event = (HttpEvent) req.getAttribute(HTTP_EVENT);
           if (event == null) return action;
           resumed.offer(event);
           event.close();
        }
        return action;
    }
View Full Code Here

Examples of org.jboss.servlet.http.HttpEvent

    @Override
    public void action(AtmosphereResourceImpl actionEvent) {
        super.action(actionEvent);
        if (actionEvent.action().type == Action.TYPE.RESUME && actionEvent.isInScope()) {
            try {
                HttpEvent event = (HttpEvent) actionEvent.getRequest().getAttribute(HTTP_EVENT);
                resumed.offer(event);
                // Resume without closing the underlying suspended connection.
                if (config.getInitParameter(AtmosphereServlet.RESUME_AND_KEEPALIVE) == null
                        || config.getInitParameter(AtmosphereServlet.RESUME_AND_KEEPALIVE).equalsIgnoreCase("false")) {
                    event.close();
                }
            } catch (IOException ex) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE, "", ex);
                }
View Full Code Here

Examples of org.jboss.servlet.http.HttpEvent

        } finally {
            CometEvent event = (CometEvent) req.getAttribute(TomcatCometSupport.COMET_EVENT);
            if (event != null)
                event.close();

            HttpEvent he = (HttpEvent) req.getAttribute(JBossWebCometSupport.HTTP_EVENT);
            if (he != null)
                he.close();
        }
        return action;
    }
View Full Code Here

Examples of org.jboss.servlet.http.HttpEvent

              log.warn("No active events to resume with");
              return;
            }

            Iterator<HttpEvent> iter = activeSessEvents.iterator();
            HttpEvent et;
            transmitMessages((et = iter.next()).getHttpServletResponse(), queue);
            iter.remove();
            et.close();
          }
          catch (Exception e) {
            e.printStackTrace();
          }
        }
View Full Code Here

Examples of org.jboss.servlet.http.HttpEvent

              log.warn("No active events to resume with");
              return;
            }

            Iterator<HttpEvent> iter = activeSessEvents.iterator();
            HttpEvent et;
            transmitMessages((et = iter.next()).getHttpServletResponse(), queue);
            iter.remove();
            et.close();
          }
          catch (Exception e) {
            e.printStackTrace();
          }
        }
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.