KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > server > dispatch > FilterConfigImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.server.dispatch;
31
32 import com.caucho.config.Config;
33 import com.caucho.config.ConfigException;
34 import com.caucho.config.types.InitParam;
35 import com.caucho.config.types.InitProgram;
36 import com.caucho.server.util.CauchoSystem;
37 import com.caucho.util.L10N;
38
39 import javax.servlet.Filter JavaDoc;
40 import javax.servlet.FilterConfig JavaDoc;
41 import javax.servlet.ServletContext JavaDoc;
42 import java.util.Collections JavaDoc;
43 import java.util.Enumeration JavaDoc;
44 import java.util.HashMap JavaDoc;
45 import java.util.Map JavaDoc;
46
47 /**
48  * Configuration for a filter.
49  */

50 public class FilterConfigImpl implements FilterConfig JavaDoc {
51   private static final L10N L = new L10N(FilterConfigImpl.class);
52   
53   private String JavaDoc _filterName;
54   private String JavaDoc _filterClassName;
55   private Class JavaDoc _filterClass;
56   private String JavaDoc _displayName;
57   private HashMap JavaDoc<String JavaDoc,String JavaDoc> _initParams = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
58
59   private InitProgram _init;
60
61   private ServletContext JavaDoc _servletContext;
62   
63   /**
64    * Creates a new filter configuration object.
65    */

66   public FilterConfigImpl()
67   {
68   }
69   
70   public void setId(String JavaDoc id)
71   {
72   }
73
74   /**
75    * Sets the filter name.
76    */

77   public void setFilterName(String JavaDoc name)
78   {
79     _filterName = name;
80   }
81
82   /**
83    * Gets the filter name.
84    */

85   public String JavaDoc getFilterName()
86   {
87     return _filterName;
88   }
89
90   /**
91    * Sets the filter class.
92    */

93   public void setFilterClass(String JavaDoc filterClassName)
94     throws ConfigException, ClassNotFoundException JavaDoc
95   {
96     _filterClassName = filterClassName;
97     
98     _filterClass = CauchoSystem.loadClass(filterClassName);
99
100     Config.validate(_filterClass, Filter JavaDoc.class);
101   }
102
103   /**
104    * Gets the filter name.
105    */

106   public Class JavaDoc getFilterClass()
107   {
108     return _filterClass;
109   }
110
111   /**
112    * Gets the filter name.
113    */

114   public String JavaDoc getFilterClassName()
115   {
116     return _filterClassName;
117   }
118
119   /**
120    * Sets an init-param
121    */

122   public void setInitParam(String JavaDoc param, String JavaDoc value)
123   {
124     _initParams.put(param, value);
125   }
126
127   /**
128    * Sets an init-param
129    */

130   public void setInitParam(InitParam initParam)
131   {
132     _initParams.putAll(initParam.getParameters());
133   }
134
135   /**
136    * Gets the init params
137    */

138   public Map JavaDoc getInitParamMap()
139   {
140     return _initParams;
141   }
142
143   /**
144    * Gets the init params
145    */

146   public String JavaDoc getInitParameter(String JavaDoc name)
147   {
148     return _initParams.get(name);
149   }
150
151   /**
152    * Gets the init params
153    */

154   public Enumeration JavaDoc getInitParameterNames()
155   {
156     return Collections.enumeration(_initParams.keySet());
157   }
158
159   /**
160    * Returns the servlet context.
161    */

162   public ServletContext JavaDoc getServletContext()
163   {
164     return _servletContext;
165   }
166
167   /**
168    * Sets the servlet context.
169    */

170   public void setServletContext(ServletContext JavaDoc app)
171   {
172     _servletContext = app;
173   }
174
175   /**
176    * Sets the init block
177    */

178   public void setInit(InitProgram init)
179   {
180     _init = init;
181   }
182
183   /**
184    * Gets the init block
185    */

186   public InitProgram getInit()
187   {
188     return _init;
189   }
190
191   /**
192    * Sets the display name
193    */

194   public void setDisplayName(String JavaDoc displayName)
195   {
196     _displayName = displayName;
197   }
198
199   /**
200    * Gets the display name
201    */

202   public String JavaDoc getDisplayName()
203   {
204     return _displayName;
205   }
206
207   /**
208    * Sets the description
209    */

210   public void setDescription(String JavaDoc description)
211   {
212   }
213
214   /**
215    * Sets the icon
216    */

217   public void setIcon(String JavaDoc icon)
218   {
219   }
220
221   /**
222    * Returns a printable representation of the filter config object.
223    */

224   public String JavaDoc toString()
225   {
226     return "FilterConfigImpl[name=" + _filterName + ",class=" + _filterClass + "]";
227   }
228 }
229
Popular Tags