KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > jetty > JettyFilterHolder


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.jetty;
18
19 import java.util.Map JavaDoc;
20
21 import org.apache.geronimo.gbean.GBeanInfo;
22 import org.apache.geronimo.gbean.GBeanInfoBuilder;
23 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
24 import org.mortbay.jetty.servlet.FilterHolder;
25 import org.mortbay.jetty.servlet.WebApplicationHandler;
26
27 /**
28  * @version $Rev: $ $Date: $
29  */

30 public class JettyFilterHolder extends FilterHolder {
31
32     //todo consider an interface instead of this constructor for endpoint use.
33
public JettyFilterHolder() {
34     }
35
36     public JettyFilterHolder(String JavaDoc filterName, String JavaDoc filterClass, Map JavaDoc initParams, JettyServletRegistration jettyServletRegistration) throws Exception JavaDoc {
37         super(jettyServletRegistration == null? null: jettyServletRegistration.getServletHandler(), filterName, filterClass);
38         if (jettyServletRegistration != null) {
39             ((WebApplicationHandler)jettyServletRegistration.getServletHandler()).addFilterHolder(this);
40             putAll(initParams);
41             start();
42         }
43     }
44
45     public String JavaDoc getFilterName() {
46         return getName();
47     }
48
49     public static final GBeanInfo GBEAN_INFO;
50
51     static {
52         GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder(JettyFilterHolder.class, NameFactory.WEB_FILTER);
53         infoBuilder.addAttribute("filterName", String JavaDoc.class, true);
54         infoBuilder.addAttribute("filterClass", String JavaDoc.class, true);
55         infoBuilder.addAttribute("initParams", Map JavaDoc.class, true);
56
57         infoBuilder.addReference("JettyServletRegistration", JettyServletRegistration.class, NameFactory.WEB_MODULE);
58
59         infoBuilder.setConstructor(new String JavaDoc[] {"filterName", "filterClass", "initParams", "JettyServletRegistration"});
60
61         GBEAN_INFO = infoBuilder.getBeanInfo();
62
63     }
64
65     public static GBeanInfo getGBeanInfo() {
66         return GBEAN_INFO;
67     }
68
69 }
70
Popular Tags