KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
27 import org.w3c.dom.Node JavaDoc;
28
29 import com.sun.enterprise.deployment.xml.WebServicesTagNames;
30 import com.sun.enterprise.deployment.WebService;
31 import com.sun.enterprise.deployment.WebServiceEndpoint;
32 import javax.xml.namespace.QName JavaDoc;
33
34 /**
35  * This node is responsible for loading web services
36  * reference information
37  *
38  * @author Kenneth Saks
39  */

40 public class WebServiceNode extends DisplayableComponentNode {
41
42     private final static XMLElement tag =
43         new XMLElement(WebServicesTagNames.WEB_SERVICE);
44
45     public WebServiceNode() {
46         super();
47         registerElementHandler
48             (new XMLElement(WebServicesTagNames.PORT_COMPONENT),
49              WebServiceEndpointNode.class);
50     }
51
52     /**
53      * initilizer method after instance creation
54      */

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

65     protected Map getDispatchTable() {
66         Map table = super.getDispatchTable();
67         table.put(WebServicesTagNames.WEB_SERVICE_DESCRIPTION_NAME,
68                   "setName");
69         table.put(WebServicesTagNames.WSDL_FILE, "setWsdlFileUri");
70         table.put(WebServicesTagNames.JAXRPC_MAPPING_FILE, "setMappingFileUri");
71         return table;
72     }
73
74     /**
75      * @return the XML tag associated with this XMLNode
76      */

77     protected XMLElement getXMLRootTag() {
78         return tag;
79     }
80
81     /**
82      * Adds a new DOL descriptor instance to the descriptor
83      * instance associated with this XMLNode
84      *
85      * @param descriptor the new descriptor
86      */

87     public void addDescriptor(Object JavaDoc descriptor) {
88         WebServiceEndpoint endpoint = (WebServiceEndpoint) descriptor;
89         WebService webService = (WebService) getDescriptor();
90         webService.addEndpoint(endpoint);
91     }
92
93     /**
94      * write the method descriptor class to a query-method DOM tree and
95      * return it
96      *
97      * @param parent node in the DOM tree
98      * @param node name for the root element of this xml fragment
99      * @param the descriptor to write
100      * @return the DOM tree top node
101      */

102     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
103                                 WebService descriptor) {
104         Node JavaDoc topNode =
105             super.writeDescriptor(parent, nodeName, descriptor);
106
107         writeDisplayableComponentInfo(topNode, descriptor);
108
109         appendTextChild(topNode,
110                         WebServicesTagNames.WEB_SERVICE_DESCRIPTION_NAME,
111                         descriptor.getName());
112         appendTextChild(topNode, WebServicesTagNames.WSDL_FILE,
113                         descriptor.getWsdlFileUri());
114         appendTextChild(topNode, WebServicesTagNames.JAXRPC_MAPPING_FILE,
115                         descriptor.getMappingFileUri());
116         
117         WebServiceEndpointNode endpointNode = new WebServiceEndpointNode();
118         for(WebServiceEndpoint next : descriptor.getEndpoints()) {
119             endpointNode.writeDescriptor
120                 (topNode, WebServicesTagNames.PORT_COMPONENT, next);
121         }
122
123         return topNode;
124     }
125     
126 }
127
Popular Tags