KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > WebServiceHandlerChainNode


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;
25
26 import java.util.Iterator JavaDoc;
27 import java.util.Map JavaDoc;
28 import java.util.logging.Level JavaDoc;
29
30 import java.util.List JavaDoc;
31 import org.w3c.dom.Node JavaDoc;
32 import org.xml.sax.Attributes JavaDoc;
33
34 import javax.xml.namespace.QName JavaDoc;
35
36 import com.sun.enterprise.deployment.util.DOLUtils;
37 import com.sun.enterprise.deployment.WebServiceHandlerChain;
38 import com.sun.enterprise.deployment.xml.TagNames;
39 import com.sun.enterprise.deployment.xml.WebServicesTagNames;
40
41 public class WebServiceHandlerChainNode extends DisplayableComponentNode {
42
43     private final static XMLElement tag =
44         new XMLElement(WebServicesTagNames.HANDLER_CHAIN);
45
46     public WebServiceHandlerChainNode() {
47         super();
48         registerElementHandler
49             (new XMLElement(WebServicesTagNames.HANDLER),
50              WebServiceHandlerNode.class, "addHandler");
51     }
52
53     /**
54      * @return the XML tag associated with this XMLNode
55      */

56     protected XMLElement getXMLRootTag() {
57         return tag;
58     }
59     
60     /**
61      * all sub-implementation of this class can use a dispatch table to map xml element to
62      * method name on the descriptor class for setting the element value.
63      *
64      * @return the map with the element name as a key, the setter method as a value
65      */

66     protected Map JavaDoc getDispatchTable() {
67         Map JavaDoc table = super.getDispatchTable();
68         table.put(WebServicesTagNames.SERVICE_NAME_PATTERN, "setServiceNamePattern");
69         table.put(WebServicesTagNames.PORT_NAME_PATTERN, "setPortNamePattern");
70         table.put(WebServicesTagNames.PROTOCOL_BINDINGS, "setProtocolBindings");
71         return table;
72     }
73
74     /**
75      * receives notification of the value for a particular tag
76      *
77      * @param element the xml element
78      * @param value it's associated value
79      */

80     public void setElementValue(XMLElement element, String JavaDoc value) {
81         super.setElementValue(element, value);
82     }
83     
84     /**
85      * write the method descriptor class to a query-method DOM tree and
86      * return it
87      *
88      * @param parent node in the DOM tree
89      * @param node name for the root element of this xml fragment
90      * @param the descriptor to write
91      * @return the DOM tree top node
92      */

93     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
94                                 WebServiceHandlerChain handler) {
95         Node JavaDoc wshNode = super.writeDescriptor(parent, nodeName, handler);
96
97         if(handler.getServiceNamePattern() != null) {
98             appendTextChild(wshNode,
99                         WebServicesTagNames.SERVICE_NAME_PATTERN,
100                         handler.getServiceNamePattern());
101         }
102         if(handler.getPortNamePattern() != null) {
103             appendTextChild(wshNode,
104                         WebServicesTagNames.PORT_NAME_PATTERN,
105                         handler.getPortNamePattern());
106         }
107         if(handler.getProtocolBindings() != null) {
108             appendTextChild(wshNode,
109                         WebServicesTagNames.PROTOCOL_BINDINGS,
110                         handler.getProtocolBindings());
111         }
112         WebServiceHandlerNode handlerNode = new WebServiceHandlerNode();
113         handlerNode.writeWebServiceHandlers(wshNode, handler.getHandlers());
114         return wshNode;
115     }
116
117     public void writeWebServiceHandlerChains(Node JavaDoc parent, List JavaDoc handlerChain) {
118         // If there are HanderChains, add the <handler-chains> node before adding
119
// individual <handler-chain> nodes
120
if(handlerChain.size() != 0) {
121             parent = super.writeDescriptor(parent, WebServicesTagNames.HANDLER_CHAINS, null);
122         }
123         for(Iterator JavaDoc iter = handlerChain.iterator(); iter.hasNext();) {
124             WebServiceHandlerChain next = (WebServiceHandlerChain) iter.next();
125             writeDescriptor(parent, WebServicesTagNames.HANDLER_CHAIN, next);
126         }
127     }
128
129 }
130
Popular Tags