KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > filters > MgnlContextFilter


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.filters;
14
15 import info.magnolia.context.MgnlContext;
16
17 import java.io.IOException JavaDoc;
18
19 import javax.servlet.Filter JavaDoc;
20 import javax.servlet.FilterChain JavaDoc;
21 import javax.servlet.FilterConfig JavaDoc;
22 import javax.servlet.ServletException JavaDoc;
23 import javax.servlet.ServletRequest JavaDoc;
24 import javax.servlet.ServletResponse JavaDoc;
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26
27
28 /**
29  * This class initializes the current context.
30  * @author Philipp Bracher
31  * @version $Revision: 6341 $ ($Author: philipp $)
32  */

33 public class MgnlContextFilter implements Filter JavaDoc {
34
35     public void init(FilterConfig JavaDoc conf) throws ServletException JavaDoc {
36     }
37
38     public void doFilter(ServletRequest JavaDoc request, ServletResponse JavaDoc response, FilterChain JavaDoc chain) throws IOException JavaDoc,
39         ServletException JavaDoc {
40
41         if (!MgnlContext.hasInstance()) {
42             MgnlContext.initAsWebContext((HttpServletRequest JavaDoc) request);
43         }
44
45         chain.doFilter(request, response);
46
47         MgnlContext.setInstance(null);
48     }
49
50     public void destroy() {
51     }
52 }
53
Popular Tags