KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > acegi > CustomContextHolderAwareRequestFilter


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */

16 package com.blandware.atleap.webapp.acegi;
17
18 import javax.servlet.*;
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import java.io.IOException JavaDoc;
21
22 /**
23  * A <code>Filter</code> which populates the <code>ServletRequest</code> with
24  * an {@link CustomContextHolderAwareRequestWrapper}.
25
26  * <p><a HREF="CustomContextHolderAwareRequestFilter.java.htm"><i>View Source</i></a></p>
27  *
28  * @author Andrey Grebnev <a HREF="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
29  * @version $Revision: 1.2 $ $Date: 2005/08/05 17:48:10 $
30  * @web.filter name="contextHolderAwareRequestFilter"
31  */

32 public class CustomContextHolderAwareRequestFilter implements Filter {
33
34     //~ Methods ================================================================
35

36     /**
37      * Destroys filter
38      */

39     public void destroy() {}
40
41     /**
42      * Performs filtering: just makes sure that request is an instance of
43      * CustomContextHolderAwareRequestWrapper
44      *
45      * @param servletRequest Request being processed
46      * @param servletResponse Response being generated
47      * @param filterChain Next filters
48      * @throws IOException
49      * @throws ServletException
50      */

51     public void doFilter(ServletRequest JavaDoc servletRequest,
52         ServletResponse servletResponse, FilterChain filterChain)
53         throws IOException JavaDoc, ServletException {
54         HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) servletRequest;
55
56         if (!(request instanceof CustomContextHolderAwareRequestWrapper)) {
57             request = new CustomContextHolderAwareRequestWrapper(request);
58         }
59
60         filterChain.doFilter(request, servletResponse);
61     }
62
63     /**
64      * Inits filter
65      *
66      * @param filterConfig Filter config
67      * @throws ServletException
68      */

69     public void init(FilterConfig filterConfig) throws ServletException {}
70 }
71
Popular Tags