Coverage details for org.chwf.servlet.filter.FilterSupport

LineHitsSource
1 /*
2 Chrysalis Web Framework [http://chrysalis.sourceforge.net]
3 Copyright (c) 2002, 2003, 2004, Paul Strack
4  
5 All rights reserved.
6  
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9  
10 1. Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12  
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16  
17 3. Neither the name of the copyright holder nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20  
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32  
33 package org.chwf.servlet.filter;
34  
35 import java.io.IOException;
36  
37 import javax.servlet.Filter;
38 import javax.servlet.FilterChain;
39 import javax.servlet.FilterConfig;
40 import javax.servlet.ServletException;
41 import javax.servlet.ServletRequest;
42 import javax.servlet.ServletResponse;
43 import javax.servlet.http.HttpServletRequest;
44 import javax.servlet.http.HttpServletResponse;
45  
46 /**
47  * <p>Filter superclass with dummy methods to simplify filter creation. It
48  * based on the same principle as the TagSupport classes.</p>
49  *
50  * @author <a href="mailto:pfstrack@users.sourceforge.net">Paul Strack</a>
51  */
52126public class FilterSupport implements Filter {
53  
54   /** Instance variable holding the config. */
55   private FilterConfig config;
56  
57   /**
58    * Called by the web container to indicate to a filter that it is being
59    * placed into service. The servlet container calls the init method exactly
60    * once after instantiating the filter. The init method must complete
61    * successfully before the filter is asked to do any filtering work.
62    *
63    * <p>The dummy method stores the config in an instance variable.</p>
64    *
65    * @param config The filter config.
66    * @throws ServletException Will prevent the filter from being initialized.
67    */
68   public void init(FilterConfig config) throws ServletException {
6962    this.config = config;
7062  }
71  
72   /**
73    * The doFilter method of the Filter is called by the container each time a
74    * request/response pair is passed through the chain due to a client request
75    * for a resource at the end of the chain. The FilterChain passed in to this
76    * method allows the Filter to pass on the request and response to the next
77    * entity in the chain.
78    *
79    * <p>The dummy method delegates to doHttpFilter()</p>
80    *
81    * @param request The request.
82    * @param response The response.
83    * @param chain The filter chain.
84    * @throws ServletException For servlet errors.
85    * @throws IOException For I/O errors.
86    */
87   public void doFilter(
88     ServletRequest request,
89     ServletResponse response,
90     FilterChain chain)
91     throws IOException, ServletException {
92     
9335    HttpServletRequest httpRequest = (HttpServletRequest) request;
9435    HttpServletResponse httpResponse = (HttpServletResponse) response;
9535    doHttpFilter(httpRequest, httpResponse, chain);
9633  }
97  
98   /**
99    * A <code>doFilter()</code> method for HTTP filters (the norm).
100    *
101    * <p>The dummy method invokes the next filter in the chain. This method
102    * should be overridden by subclasses.</p>
103    *
104    * @param request The request.
105    * @param response The response.
106    * @param chain The filter chain.
107    * @throws ServletException For servlet errors.
108    * @throws IOException For I/O errors.
109    */
110   public void doHttpFilter(
111     HttpServletRequest request,
112     HttpServletResponse response,
113     FilterChain chain)
114     throws IOException, ServletException {
11510    chain.doFilter(request, response);
11610  }
117  
118   /**
119    * Called by the web container to indicate to a filter that it is being taken
120    * out of service. This method is only called once all threads within the
121    * filter's doFilter method have exited or after a timeout period has passed.
122    * After the web container calls this method, it will not call the doFilter
123    * method again on this instance of the filter.
124    *
125    * <p>The dummy method does nothing.</p>
126    */
127   public void destroy() {
128     // Do nothing
1293  }
130  
131   /**
132    * Get FilterConfig.
133    *
134    * @return The FilterConfig.
135    */
136   protected FilterConfig getConfig() {
1370    return config;
138   }
139 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.