Package org.apache.catalina

Examples of org.apache.catalina.CometEvent


                        if (activeSessEvents == null || activeSessEvents.isEmpty()) {
                            //        log.error("Nothing active man");
                            return;
                        }

                        CometEvent et = activeSessEvents.iterator().next();

                        if (et == null) {
                            return;
                        }

                        try {
                            transmitMessages(et.getHttpServletResponse(), queue);
                        }
                        catch (NullPointerException e) {
                            activeSessEvents.remove(et);
                            return;
                        }

                        try {
                            et.close();
                        }
                        catch (NullPointerException e) {
                            // suppress.
                        }
View Full Code Here


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

        CometEvent event = (CometEvent) req.getAttribute(COMET_EVENT);

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

        Action action = null;
        // For now, we are just interested in CometEvent.READ
        if (event.getEventType() == EventType.BEGIN) {
            action = suspended(req, res);
            if (action.type() == Action.TYPE.SUSPEND) {
                // Do nothing except setting the times out
                try {
                    if (action.timeout() != -1) {
                        event.setTimeout((int) action.timeout());
                    } else {
                        event.setTimeout(Integer.MAX_VALUE);
                    }
                    req.setAttribute(SUSPENDED, true);
                } catch (UnsupportedOperationException ex) {
                    // TODO: Must implement the same functionality using a Scheduler
                    logger.trace("Warning: CometEvent.setTimeout not supported on this Tomcat instance. " +
                            " [The Tomcat native connector does not support timeouts on asynchronous I/O.]");
                }
                req.setAttribute(SUSPENDED, true);
            } else {
                try {
                    event.close();
                } catch (IllegalStateException ex) {
                    logger.trace("event.close", ex);
                }
            }
        } else if (event.getEventType() == EventType.READ) {
            // Not implemented
        } else if (event.getEventSubType() == CometEvent.EventSubType.CLIENT_DISCONNECT) {

            if (req.getAttribute(SUSPENDED) != null && closeConnectionOnInputStream) {
                req.setAttribute(SUSPENDED, null);
                action = cancelled(req, res);
            }

            try {
                event.close();
            } catch (IllegalStateException ex) {
                logger.trace("event.close", ex);
            }
        } else if (event.getEventSubType() == CometEvent.EventSubType.TIMEOUT) {

            action = timedout(req, res);
            try {
                event.close();
            } catch (IllegalStateException ex) {
                logger.trace("event.close", ex);
            }
        } else if (event.getEventType() == EventType.ERROR) {
            try {
                event.close();
            } catch (IllegalStateException ex) {
                logger.trace("event.close", ex);
            }
        } else if (event.getEventType() == EventType.END) {
            if (req.resource() != null && req.resource().isResumed()) {
                AtmosphereResourceImpl.class.cast(req.resource()).cancel();
            } else if (req.getAttribute(SUSPENDED) != null && closeConnectionOnInputStream) {
                req.setAttribute(SUSPENDED, null);
                action = cancelled(req, res);
            } else {
                try {
                    event.close();
                } catch (IllegalStateException ex) {
                    logger.trace("event.close", ex);
                }
            }
        }
View Full Code Here

    }

    @Override
    public AsyncSupport complete(AtmosphereResourceImpl r) {
        try {
            CometEvent event = (CometEvent) r.getRequest(false).getAttribute(COMET_EVENT);
            if (event == null) return this;

            try {
                event.close();
            } catch (IllegalStateException ex) {
                logger.trace("event.close", ex);
            }
        } catch (IOException ex) {
            logger.debug("action failed", ex);
View Full Code Here

    public Action cancelled(AtmosphereRequest req, AtmosphereResponse res)
            throws IOException, ServletException {

        Action action = super.cancelled(req, res);
        if (req.getAttribute(MAX_INACTIVE) != null && Long.class.cast(req.getAttribute(MAX_INACTIVE)) == -1) {
            CometEvent event = (CometEvent) req.getAttribute(COMET_EVENT);
            if (event == null) return action;
            try {
                event.close();
            } catch (IllegalStateException ex) {
                logger.trace("event.close", ex);
            }
        }
        return action;
View Full Code Here

   
    }

    req.setAttribute("de.jochenbrissier.byw.comet", "noneTomcat");

    event(new CometEvent() {

      @Override
      public void setTimeout(int arg0) throws IOException,
          ServletException, UnsupportedOperationException {
        // TODO Auto-generated method stub
View Full Code Here

    }

    req.setAttribute("de.jochenbrissier.byw.comet", "noneTomcat");

    event(new CometEvent() {

      @Override
      public void setTimeout(int arg0) throws IOException,
          ServletException, UnsupportedOperationException {
        // TODO Auto-generated method stub
View Full Code Here

   
    }

    req.setAttribute("de.jochenbrissier.byw.comet", "noneTomcat");

    event(new CometEvent() {

      @Override
      public void setTimeout(int arg0) throws IOException,
          ServletException, UnsupportedOperationException {
        // TODO Auto-generated method stub
View Full Code Here

     */
    public void doFilterEvent(CometEvent event)
        throws IOException, ServletException {

        if( System.getSecurityManager() != null ) {
            final CometEvent ev = event;
            try {
                java.security.AccessController.doPrivileged(
                    new java.security.PrivilegedExceptionAction() {
                        public Object run()
                            throws ServletException, IOException {
View Full Code Here

                support.fireInstanceEvent(InstanceEvent.BEFORE_FILTER_EVENT,
                        filter, event);
                        */

                if( System.getSecurityManager() != null ) {
                    final CometEvent ev = event;
                    Principal principal =
                        ev.getHttpServletRequest().getUserPrincipal();

                    Object[] args = new Object[]{ev, this};
                    SecurityUtil.doAsPrivilege
                        ("doFilterEvent", (Filter) filter, cometClassType, args);

                    args = null;
                } else
                    filter.doFilterEvent(event, this);
                }

                /*support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
                        filter, event);*/
            } catch (IOException e) {
                /*
                if (filter != null)
                    support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
                            filter, event, e);
                            */
                throw e;
            } catch (ServletException e) {
                /*
                if (filter != null)
                    support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
                            filter, event, e);
                            */
                throw e;
            } catch (RuntimeException e) {
                /*
                if (filter != null)
                    support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
                            filter, event, e);
                            */
                throw e;
            } catch (Throwable e) {
                /*if (filter != null)
                    support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
                            filter, event, e);*/
                throw new ServletException
                    (sm.getString("filterChain.filter"), e);
            }
            return;
        }

        // We fell off the end of the chain -- call the servlet instance
        try {
            /*
            support.fireInstanceEvent(InstanceEvent.BEFORE_SERVICE_EVENT,
                    servlet, request, response);
                    */
            if( System.getSecurityManager() != null ) {
                final CometEvent ev = event;
                Principal principal =
                    ev.getHttpServletRequest().getUserPrincipal();
                Object[] args = new Object[]{ ev };
                SecurityUtil.doAsPrivilege("event",
                        servlet,
                        classTypeUsedInEvent,
                        args,
View Full Code Here

     */
    public void doFilterEvent(CometEvent event)
        throws IOException, ServletException {

        if( Globals.IS_SECURITY_ENABLED ) {
            final CometEvent ev = event;
            try {
                java.security.AccessController.doPrivileged(
                    new java.security.PrivilegedExceptionAction() {
                        public Object run()
                            throws ServletException, IOException {
View Full Code Here

TOP

Related Classes of org.apache.catalina.CometEvent

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.