01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License. For additional information regarding
15: * copyright in this work, please see the NOTICE file in the top level
16: * directory of this distribution.
17: */
18:
19: package org.apache.roller.ui.core.filters;
20:
21: import java.io.IOException;
22: import javax.servlet.Filter;
23: import javax.servlet.FilterChain;
24: import javax.servlet.FilterConfig;
25: import javax.servlet.ServletException;
26: import javax.servlet.ServletRequest;
27: import javax.servlet.ServletResponse;
28: import javax.servlet.http.HttpServletRequest;
29: import javax.servlet.http.HttpServletResponse;
30: import org.apache.commons.logging.Log;
31: import org.apache.commons.logging.LogFactory;
32:
33: /**
34: * A simple debugging filter.
35: *
36: * This filter is NOT mapped by default and is here only for Roller developers
37: * to use while they are working on the code and debugging things.
38: *
39: * @web.filter name="DebugFilter"
40: */
41: public class DebugFilter implements Filter {
42:
43: private static Log log = LogFactory.getLog(DebugFilter.class);
44:
45: public void doFilter(ServletRequest req, ServletResponse res,
46: FilterChain chain) throws IOException, ServletException {
47:
48: HttpServletRequest request = (HttpServletRequest) req;
49: HttpServletResponse response = (HttpServletResponse) res;
50:
51: log.info("ENTERING " + request.getRequestURL());
52:
53: // some info about the request and response
54: log.info("Response Object:");
55: log.info(" isCommited = " + response.isCommitted());
56: log.info(" bufferSize = " + response.getBufferSize());
57: log.info("");
58:
59: chain.doFilter(request, response);
60:
61: log.info("EXITING " + request.getRequestURL());
62:
63: // some info about the request and response
64: log.info("Response Object:");
65: log.info(" isCommited = " + response.isCommitted());
66: log.info(" bufferSize = " + response.getBufferSize());
67: log.info("");
68: }
69:
70: public void destroy() {
71: }
72:
73: public void init(FilterConfig filterConfig) {
74: }
75:
76: }
|