Java 类org.apache.catalina.comet.CometEvent 实例源码

项目:tomcat7    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[])
        se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor)
                        req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger().warn(sm.getString(
                        "cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[])
        se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor)
                        req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger().warn(sm.getString(
                        "cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:lazycat    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[]) se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor) req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger()
                        .warn(sm.getString("cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChatServlet.java   
protected void begin(@SuppressWarnings("unused") CometEvent event,
        HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Begin for session: " + request.getSession(true).getId());

    response.setContentType("text/html; charset=" + CHARSET);

    PrintWriter writer = response.getWriter();
    writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
    writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
    writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
    writer.flush();

    synchronized(connections) {
        connections.add(response);
    }

    messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChatServlet.java   
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    InputStream is = request.getInputStream();
    byte[] buf = new byte[512];
    while (is.available() > 0) {
        log("Available: " + is.available());
        int n = is.read(buf);
        if (n > 0) {
            log("Read " + n + " bytes: " + new String(buf, 0, n)
                    + " for session: " + request.getSession(true).getId());
        } else if (n < 0) {
            log("End of file: " + n);
            end(event, request, response);
            return;
        }
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChatServlet.java   
protected void begin(@SuppressWarnings("unused") CometEvent event,
        HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Begin for session: " + request.getSession(true).getId());

    response.setContentType("text/html; charset=" + CHARSET);

    PrintWriter writer = response.getWriter();
    writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
    writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
    writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
    writer.flush();

    synchronized(connections) {
        connections.add(response);
    }

    messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChatServlet.java   
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    InputStream is = request.getInputStream();
    byte[] buf = new byte[512];
    while (is.available() > 0) {
        log("Available: " + is.available());
        int n = is.read(buf);
        if (n > 0) {
            log("Read " + n + " bytes: " + new String(buf, 0, n)
                    + " for session: " + request.getSession(true).getId());
        } else if (n < 0) {
            log("End of file: " + n);
            end(event, request, response);
            return;
        }
    }
}
项目:class-guard    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[])
        se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor)
                        req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger().warn(sm.getString(
                        "cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:class-guard    文件:ChatServlet.java   
protected void begin(@SuppressWarnings("unused") CometEvent event,
        HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Begin for session: " + request.getSession(true).getId());

    response.setContentType("text/html; charset=" + CHARSET);

    PrintWriter writer = response.getWriter();
    writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
    writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
    writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
    writer.flush();

    synchronized(connections) {
        connections.add(response);
    }

    messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
项目:class-guard    文件:ChatServlet.java   
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    InputStream is = request.getInputStream();
    byte[] buf = new byte[512];
    while (is.available() > 0) {
        log("Available: " + is.available());
        int n = is.read(buf);
        if (n > 0) {
            log("Read " + n + " bytes: " + new String(buf, 0, n)
                    + " for session: " + request.getSession(true).getId());
        } else if (n < 0) {
            log("End of file: " + n);
            end(event, request, response);
            return;
        }
    }
}
项目:apache-tomcat-7.0.57    文件:ChatServlet.java   
protected void begin(@SuppressWarnings("unused") CometEvent event,
        HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Begin for session: " + request.getSession(true).getId());

    response.setContentType("text/html; charset=" + CHARSET);

    PrintWriter writer = response.getWriter();
    writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
    writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
    writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
    writer.flush();

    synchronized(connections) {
        connections.add(response);
    }

    messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
项目:apache-tomcat-7.0.57    文件:ChatServlet.java   
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    InputStream is = request.getInputStream();
    byte[] buf = new byte[512];
    while (is.available() > 0) {
        log("Available: " + is.available());
        int n = is.read(buf);
        if (n > 0) {
            log("Read " + n + " bytes: " + new String(buf, 0, n)
                    + " for session: " + request.getSession(true).getId());
        } else if (n < 0) {
            log("End of file: " + n);
            end(event, request, response);
            return;
        }
    }
}
项目:apache-tomcat-7.0.57    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[])
        se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor)
                        req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger().warn(sm.getString(
                        "cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:apache-tomcat-7.0.57    文件:ChatServlet.java   
protected void begin(@SuppressWarnings("unused") CometEvent event,
        HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Begin for session: " + request.getSession(true).getId());

    response.setContentType("text/html; charset=" + CHARSET);

    PrintWriter writer = response.getWriter();
    writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
    writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
    writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
    writer.flush();

    synchronized(connections) {
        connections.add(response);
    }

    messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
项目:apache-tomcat-7.0.57    文件:ChatServlet.java   
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    InputStream is = request.getInputStream();
    byte[] buf = new byte[512];
    while (is.available() > 0) {
        log("Available: " + is.available());
        int n = is.read(buf);
        if (n > 0) {
            log("Read " + n + " bytes: " + new String(buf, 0, n)
                    + " for session: " + request.getSession(true).getId());
        } else if (n < 0) {
            log("End of file: " + n);
            end(event, request, response);
            return;
        }
    }
}
项目:apache-tomcat-7.0.57    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[])
        se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor)
                        req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger().warn(sm.getString(
                        "cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:WBSAirback    文件:CometConnectionManagerValve.java   
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    // Close all Comet connections associated with this session
    Request[] reqs = (Request[])
        se.getSession().getAttribute(cometRequestsAttribute);
    if (reqs != null) {
        for (int i = 0; i < reqs.length; i++) {
            Request req = reqs[i];
            try {
                CometEventImpl event = req.getEvent();
                event.setEventType(CometEvent.EventType.END);
                event.setEventSubType(CometEvent.EventSubType.SESSION_END);
                ((CometProcessor)
                        req.getWrapper().getServlet()).event(event);
                event.close();
            } catch (Exception e) {
                req.getWrapper().getParent().getLogger().warn(sm.getString(
                        "cometConnectionManagerValve.listenerEvent"), e);
            }
        }
    }
}
项目:WBSAirback    文件:ChatServlet.java   
protected void begin(@SuppressWarnings("unused") CometEvent event,
        HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Begin for session: " + request.getSession(true).getId());

    response.setContentType("text/html; charset=" + CHARSET);

    PrintWriter writer = response.getWriter();
    writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
    writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
    writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
    writer.flush();

    synchronized(connections) {
        connections.add(response);
    }

    messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
项目:WBSAirback    文件:ChatServlet.java   
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    InputStream is = request.getInputStream();
    byte[] buf = new byte[512];
    while (is.available() > 0) {
        log("Available: " + is.available());
        int n = is.read(buf);
        if (n > 0) {
            log("Read " + n + " bytes: " + new String(buf, 0, n) 
                    + " for session: " + request.getSession(true).getId());
        } else if (n < 0) {
            log("End of file: " + n);
            end(event, request, response);
            return;
        }
    }
}
项目:WBSAirback    文件:ChatServlet.java   
protected void begin(@SuppressWarnings("unused") CometEvent event,
        HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Begin for session: " + request.getSession(true).getId());

    response.setContentType("text/html; charset=" + CHARSET);

    PrintWriter writer = response.getWriter();
    writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
    writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
    writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
    writer.flush();

    synchronized(connections) {
        connections.add(response);
    }

    messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
项目:WBSAirback    文件:ChatServlet.java   
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    InputStream is = request.getInputStream();
    byte[] buf = new byte[512];
    while (is.available() > 0) {
        log("Available: " + is.available());
        int n = is.read(buf);
        if (n > 0) {
            log("Read " + n + " bytes: " + new String(buf, 0, n) 
                    + " for session: " + request.getSession(true).getId());
        } else if (n < 0) {
            log("End of file: " + n);
            end(event, request, response);
            return;
        }
    }
}
项目:orbeon-forms    文件:ChatServlet.java   
protected void begin(@SuppressWarnings("unused") CometEvent event,
        HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Begin for session: " + request.getSession(true).getId());

    response.setContentType("text/html; charset=" + CHARSET);

    PrintWriter writer = response.getWriter();
    writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
    writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
    writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
    writer.flush();

    synchronized(connections) {
        connections.add(response);
    }

    messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
项目:orbeon-forms    文件:ChatServlet.java   
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    InputStream is = request.getInputStream();
    byte[] buf = new byte[512];
    while (is.available() > 0) {
        log("Available: " + is.available());
        int n = is.read(buf);
        if (n > 0) {
            log("Read " + n + " bytes: " + new String(buf, 0, n)
                    + " for session: " + request.getSession(true).getId());
        } else if (n < 0) {
            log("End of file: " + n);
            end(event, request, response);
            return;
        }
    }
}
项目:tomcat7    文件:RequestFilter.java   
/**
 * Perform the filtering that has been configured for this Filter, matching
 * against the specified request property.
 * 
 * @param property  The property to check against the allow/deny rules
 * @param event     The comet event to be filtered
 * @param chain     The comet filter chain
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
protected void processCometEvent(String property, CometEvent event,
        CometFilterChain chain) throws IOException, ServletException {
    HttpServletResponse response = event.getHttpServletResponse();

    if (isAllowed(property)) {
        chain.doFilterEvent(event);
    } else {
        response.sendError(denyStatus);
        event.close();
    }
}
项目:tomcat7    文件:FailedRequestFilter.java   
@Override
public void doFilterEvent(CometEvent event, CometFilterChain chain)
        throws IOException, ServletException {
    if (event.getEventType() == CometEvent.EventType.BEGIN
            && !isGoodRequest(event.getHttpServletRequest())) {
        event.getHttpServletResponse().sendError(
                HttpServletResponse.SC_BAD_REQUEST);
        event.close();
        return;
    }
    chain.doFilterEvent(event);
}
项目:tomcat7    文件:ApplicationFilterChain.java   
/**
 * Process the event, using the security manager if the option is enabled.
 * 
 * @param event the event to process
 * 
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet exception occurs
 */
@Override
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<Void>() {
                    @Override
                    public Void run() 
                        throws ServletException, IOException {
                        internalDoFilterEvent(ev);
                        return null;
                    }
                }
            );
        } catch( PrivilegedActionException pe) {
            Exception e = pe.getException();
            if (e instanceof ServletException)
                throw (ServletException) e;
            else if (e instanceof IOException)
                throw (IOException) e;
            else if (e instanceof RuntimeException)
                throw (RuntimeException) e;
            else
                throw new ServletException(e.getMessage(), e);
        }
    } else {
        internalDoFilterEvent(event);
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:RequestFilter.java   
/**
 * Perform the filtering that has been configured for this Filter, matching
 * against the specified request property.
 * 
 * @param property  The property to check against the allow/deny rules
 * @param event     The comet event to be filtered
 * @param chain     The comet filter chain
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
protected void processCometEvent(String property, CometEvent event,
        CometFilterChain chain) throws IOException, ServletException {
    HttpServletResponse response = event.getHttpServletResponse();

    if (isAllowed(property)) {
        chain.doFilterEvent(event);
    } else {
        response.sendError(denyStatus);
        event.close();
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:FailedRequestFilter.java   
@Override
public void doFilterEvent(CometEvent event, CometFilterChain chain)
        throws IOException, ServletException {
    if (event.getEventType() == CometEvent.EventType.BEGIN
            && !isGoodRequest(event.getHttpServletRequest())) {
        event.getHttpServletResponse().sendError(
                HttpServletResponse.SC_BAD_REQUEST);
        event.close();
        return;
    }
    chain.doFilterEvent(event);
}
项目:apache-tomcat-7.0.73-with-comment    文件:ApplicationFilterChain.java   
/**
 * Process the event, using the security manager if the option is enabled.
 * 
 * @param event the event to process
 * 
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet exception occurs
 */
@Override
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<Void>() {
                    @Override
                    public Void run() 
                        throws ServletException, IOException {
                        internalDoFilterEvent(ev);
                        return null;
                    }
                }
            );
        } catch( PrivilegedActionException pe) {
            Exception e = pe.getException();
            if (e instanceof ServletException)
                throw (ServletException) e;
            else if (e instanceof IOException)
                throw (IOException) e;
            else if (e instanceof RuntimeException)
                throw (RuntimeException) e;
            else
                throw new ServletException(e.getMessage(), e);
        }
    } else {
        internalDoFilterEvent(event);
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChatServlet.java   
protected void end(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("End for session: " + request.getSession(true).getId());
    synchronized(connections) {
        connections.remove(response);
    }

    PrintWriter writer = response.getWriter();
    writer.println("</body></html>");

    event.close();
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChatServlet.java   
protected void error(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Error for session: " + request.getSession(true).getId());
    synchronized(connections) {
        connections.remove(response);
    }
    event.close();
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChatServlet.java   
protected void end(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("End for session: " + request.getSession(true).getId());
    synchronized(connections) {
        connections.remove(response);
    }

    PrintWriter writer = response.getWriter();
    writer.println("</body></html>");

    event.close();
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChatServlet.java   
protected void error(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Error for session: " + request.getSession(true).getId());
    synchronized(connections) {
        connections.remove(response);
    }
    event.close();
}
项目:lazycat    文件:FailedRequestFilter.java   
@Override
public void doFilterEvent(CometEvent event, CometFilterChain chain) throws IOException, ServletException {
    if (event.getEventType() == CometEvent.EventType.BEGIN && !isGoodRequest(event.getHttpServletRequest())) {
        event.getHttpServletResponse().sendError(HttpServletResponse.SC_BAD_REQUEST);
        event.close();
        return;
    }
    chain.doFilterEvent(event);
}
项目:lazycat    文件:ApplicationFilterChain.java   
/**
 * Process the event, using the security manager if the option is enabled.
 * 
 * @param event
 *            the event to process
 * 
 * @exception IOException
 *                if an input/output error occurs
 * @exception ServletException
 *                if a servlet exception occurs
 */
@Override
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<Void>() {
                @Override
                public Void run() throws ServletException, IOException {
                    internalDoFilterEvent(ev);
                    return null;
                }
            });
        } catch (PrivilegedActionException pe) {
            Exception e = pe.getException();
            if (e instanceof ServletException)
                throw (ServletException) e;
            else if (e instanceof IOException)
                throw (IOException) e;
            else if (e instanceof RuntimeException)
                throw (RuntimeException) e;
            else
                throw new ServletException(e.getMessage(), e);
        }
    } else {
        internalDoFilterEvent(event);
    }
}
项目:class-guard    文件:RequestFilter.java   
/**
 * Perform the filtering that has been configured for this Filter, matching
 * against the specified request property.
 * 
 * @param property  The property to check against the allow/deny rules
 * @param event     The comet event to be filtered
 * @param chain     The comet filter chain
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
protected void processCometEvent(String property, CometEvent event,
        CometFilterChain chain) throws IOException, ServletException {
    HttpServletResponse response = event.getHttpServletResponse();

    if (isAllowed(property)) {
        chain.doFilterEvent(event);
    } else {
        response.sendError(denyStatus);
        event.close();
    }
}
项目:class-guard    文件:FailedRequestFilter.java   
@Override
public void doFilterEvent(CometEvent event, CometFilterChain chain)
        throws IOException, ServletException {
    if (event.getEventType() == CometEvent.EventType.BEGIN
            && !isGoodRequest(event.getHttpServletRequest())) {
        event.getHttpServletResponse().sendError(
                HttpServletResponse.SC_BAD_REQUEST);
        event.close();
        return;
    }
    chain.doFilterEvent(event);
}
项目:class-guard    文件:ApplicationFilterChain.java   
/**
 * Process the event, using the security manager if the option is enabled.
 * 
 * @param event the event to process
 * 
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet exception occurs
 */
@Override
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<Void>() {
                    @Override
                    public Void run() 
                        throws ServletException, IOException {
                        internalDoFilterEvent(ev);
                        return null;
                    }
                }
            );
        } catch( PrivilegedActionException pe) {
            Exception e = pe.getException();
            if (e instanceof ServletException)
                throw (ServletException) e;
            else if (e instanceof IOException)
                throw (IOException) e;
            else if (e instanceof RuntimeException)
                throw (RuntimeException) e;
            else
                throw new ServletException(e.getMessage(), e);
        }
    } else {
        internalDoFilterEvent(event);
    }
}
项目:class-guard    文件:ChatServlet.java   
protected void end(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("End for session: " + request.getSession(true).getId());
    synchronized(connections) {
        connections.remove(response);
    }

    PrintWriter writer = response.getWriter();
    writer.println("</body></html>");

    event.close();
}
项目:class-guard    文件:ChatServlet.java   
protected void error(CometEvent event, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    log("Error for session: " + request.getSession(true).getId());
    synchronized(connections) {
        connections.remove(response);
    }
    event.close();
}