KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > web > FilterNode


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment.node.web;
25
26 import java.util.Map JavaDoc;
27 import java.util.Vector JavaDoc;
28 import java.util.Enumeration JavaDoc;
29 import org.w3c.dom.Node JavaDoc;
30
31 import com.sun.enterprise.deployment.ServletFilterDescriptor;
32 import com.sun.enterprise.deployment.EnvironmentProperty;
33
34 import com.sun.enterprise.deployment.node.DisplayableComponentNode;
35 import com.sun.enterprise.deployment.node.XMLElement;
36 import com.sun.enterprise.deployment.xml.WebTagNames;
37
38 /**
39  * This class is responsible for handling filter xml node
40  *
41  * @author Jerome Dochez
42  * @version
43  */

44 public class FilterNode extends DisplayableComponentNode {
45
46     // constructor. register sub nodes.
47
public FilterNode() {
48         super();
49         registerElementHandler(new XMLElement(WebTagNames.INIT_PARAM),
50                                                             InitParamNode.class, "addInitializationParameter");
51     }
52     
53     /**
54      * all sub-implementation of this class can use a dispatch table to map xml element to
55      * method name on the descriptor class for setting the element value.
56      *
57      * @return the map with the element name as a key, the setter method as a value
58      */

59     protected Map JavaDoc getDispatchTable() {
60         Map JavaDoc table = super.getDispatchTable();
61         table.put(WebTagNames.NAME, "setDisplayName");
62         table.put(WebTagNames.FILTER_NAME, "setName");
63         table.put(WebTagNames.FILTER_CLASS, "setClassName");
64         return table;
65     }
66     
67     /**
68      * write the descriptor class to a DOM tree and return it
69      *
70      * @param parent node in the DOM tree
71      * @param node name for the root element of this xml fragment
72      * @param the descriptor to write
73      * @return the DOM tree top node
74      */

75     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, ServletFilterDescriptor descriptor) {
76         Node JavaDoc myNode = appendChild(parent, nodeName);
77         writeDisplayableComponentInfo(myNode, descriptor);
78         appendTextChild(myNode, WebTagNames.FILTER_NAME, descriptor.getName());
79         appendTextChild(myNode, WebTagNames.FILTER_CLASS, descriptor.getClassName());
80         Vector JavaDoc initParams = descriptor.getInitializationParameters();
81         if (!initParams.isEmpty()) {
82             WebBundleNode.addInitParam(myNode, WebTagNames.INIT_PARAM, initParams.elements());
83         }
84         
85         return myNode;
86     }
87 }
88
Popular Tags