KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
27 import java.util.Collection JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.logging.Level JavaDoc;
31 import java.util.Map JavaDoc;
32 import java.util.Set JavaDoc;
33 import org.w3c.dom.Document JavaDoc;
34 import org.w3c.dom.Node JavaDoc;
35
36 import java.io.IOException JavaDoc;
37 import java.io.InputStream JavaDoc;
38
39 import com.sun.enterprise.deployment.Descriptor;
40 import com.sun.enterprise.deployment.WebService;
41 import com.sun.enterprise.deployment.WebServiceEndpoint;
42 import com.sun.enterprise.deployment.WebServicesDescriptor;
43 import com.sun.enterprise.deployment.BundleDescriptor;
44 import com.sun.enterprise.deployment.node.XMLElement;
45 import com.sun.enterprise.deployment.node.WebServiceNode;
46 import com.sun.enterprise.deployment.node.RootXMLNode;
47 import com.sun.enterprise.deployment.xml.WebServicesTagNames;
48 import com.sun.enterprise.deployment.xml.TagNames;
49 import com.sun.enterprise.deployment.util.DOLUtils;
50
51 /**
52  * Root node for webservices deployment descriptor
53  *
54  * @author Kenneth Saks
55  * @version
56  */

57 public class WebServicesDescriptorNode extends BundleNode
58                                     implements RootXMLNode
59 {
60     public final static XMLElement ROOT_ELEMENT =
61         new XMLElement(WebServicesTagNames.WEB_SERVICES);
62     public final static String JavaDoc SCHEMA_ID = "javaee_web_services_1_2.xsd";
63     public final static String JavaDoc SPEC_VERSION = "1.2";
64     private static List JavaDoc<String JavaDoc> systemIDs = null;
65
66     private BundleDescriptor bundleDescriptor;
67
68     public WebServicesDescriptorNode(BundleDescriptor descriptor) {
69         bundleDescriptor = descriptor;
70         registerElementHandler(new XMLElement(WebServicesTagNames.WEB_SERVICE),
71                                WebServiceNode.class);
72     }
73
74     public WebServicesDescriptorNode() {
75         this(null);
76     }
77     
78     /**
79      * @return the DOCTYPE of the XML file
80      */

81     public String JavaDoc getDocType() {
82         return null;
83     }
84     
85     /**
86      * @return the SystemID of the XML file
87      */

88     public String JavaDoc getSystemID() {
89         return SCHEMA_ID;
90     }
91
92     /**
93      * @return the list of SystemID of the XML schema supported
94      */

95     public List JavaDoc<String JavaDoc> getSystemIDs() {
96         if (systemIDs != null) {
97             return systemIDs;
98         }
99
100         systemIDs = new ArrayList JavaDoc<String JavaDoc>();
101         systemIDs.add(SCHEMA_ID);
102         return systemIDs;
103     }
104
105     /**
106      * @return the complete URL for J2EE schemas
107      */

108     protected String JavaDoc getSchemaURL() {
109        return WebServicesTagNames.IBM_NAMESPACE + "/" + getSystemID();
110     }
111     
112     /**
113      * @return the XML tag associated with this XMLNode
114      */

115     protected XMLElement getXMLRootTag() {
116         return ROOT_ELEMENT;
117     }
118     
119     /**
120      * receives notiification of the value for a particular tag
121      *
122      * @param element the xml element
123      * @param value it's associated value
124      */

125     public void setElementValue(XMLElement element, String JavaDoc value) {
126         if (TagNames.VERSION.equals(element.getQName())) {
127             bundleDescriptor.getWebServices().setSpecVersion(value);
128         } else super.setElementValue(element, value);
129     }
130         
131     /**
132      * Adds a new DOL descriptor instance to the descriptor
133      * instance associated with this XMLNode
134      *
135      * @param descriptor the new descriptor
136      */

137     public void addDescriptor(Object JavaDoc descriptor) {
138         WebServicesDescriptor webServicesDesc =
139             bundleDescriptor.getWebServices();
140         WebService webService = (WebService) descriptor;
141         webServicesDesc.addWebService(webService);
142         
143         for(Iterator JavaDoc iter = webService.getEndpoints().iterator();
144             iter.hasNext();) {
145             WebServiceEndpoint next = (WebServiceEndpoint) iter.next();
146             if( !next.resolveComponentLink() ) {
147                 DOLUtils.getDefaultLogger().info("Warning: Web service endpoint " + next.getEndpointName() + " component link " + next.getLinkName() + " is not valid");
148             }
149         }
150         
151     }
152     
153    /**
154     * @return the descriptor instance to associate with this XMLNode
155     */

156     public Object JavaDoc getDescriptor() {
157         return bundleDescriptor;
158     }
159
160     /**
161      * write the descriptor class to a DOM tree and return it
162      *
163      * @param parent node for the DOM tree
164      * @param the descriptor to write
165      * @return the DOM tree top node
166      */

167     public Node JavaDoc writeDescriptor(Node JavaDoc parent, Descriptor descriptor) {
168         Node JavaDoc topNode = parent;
169         if (parent instanceof Document JavaDoc) {
170             BundleDescriptor bundleDesc = (BundleDescriptor) descriptor;
171             WebServicesDescriptor webServicesDesc = bundleDesc.getWebServices();
172             topNode = super.writeDescriptor(parent, webServicesDesc);
173             WebServiceNode wsNode = new WebServiceNode();
174             for(WebService next : webServicesDesc.getWebServices()) {
175                 wsNode.writeDescriptor(topNode, WebServicesTagNames.WEB_SERVICE,
176                                        next);
177             }
178         }
179         return parent;
180     }
181
182     /**
183      * @return the default spec version level this node complies to
184      */

185     public String JavaDoc getSpecVersion() {
186         return SPEC_VERSION;
187     }
188     
189 }
190
191
Popular Tags