KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > module > sitemesh > Config


1 /*
2  * Title: Config
3  * Description:
4  *
5  * This software is published under the terms of the OpenSymphony Software
6  * License version 1.1, of which a copy has been included with this
7  * distribution in the LICENSE.txt file.
8  */

9
10 package com.opensymphony.module.sitemesh;
11
12 import javax.servlet.FilterConfig JavaDoc;
13 import javax.servlet.ServletConfig JavaDoc;
14 import javax.servlet.ServletContext JavaDoc;
15
16 /**
17  * Common interface to ServletConfig and FilterConfig
18  * (since javax.servlet.Config was removed from 2.3 spec).
19  *
20  * @author <a HREF="mailto:joe@truemesh.com">Joe Walnes</a>
21  * @version $Revision: 1.1 $
22  */

23 public class Config {
24     private ServletConfig JavaDoc servletConfig;
25     private FilterConfig JavaDoc filterConfig;
26
27     public Config(ServletConfig JavaDoc servletConfig) {
28         if (servletConfig == null) throw new NullPointerException JavaDoc("ServletConfig cannot be null");
29         this.servletConfig = servletConfig;
30     }
31
32     public Config(FilterConfig JavaDoc filterConfig) {
33         if (filterConfig == null) throw new NullPointerException JavaDoc("FilterConfig cannot be null");
34         this.filterConfig = filterConfig;
35     }
36
37     public ServletContext JavaDoc getServletContext() {
38         return servletConfig != null ? servletConfig.getServletContext() : filterConfig.getServletContext();
39     }
40 }
Popular Tags