KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > WebServiceRuntimeNode


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 package com.sun.enterprise.deployment.node.runtime;
24
25 import java.util.*;
26 import org.w3c.dom.Node JavaDoc;
27 import java.util.logging.Level JavaDoc;
28
29 import javax.xml.namespace.QName JavaDoc;
30 import com.sun.enterprise.deployment.node.XMLElement;
31 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
32 import com.sun.enterprise.deployment.WebServiceEndpoint;
33 import com.sun.enterprise.deployment.WebService;
34 import com.sun.enterprise.deployment.WebServicesDescriptor;
35 import com.sun.enterprise.deployment.WebBundleDescriptor;
36 import com.sun.enterprise.deployment.BundleDescriptor;
37 import com.sun.enterprise.deployment.EjbBundleDescriptor;
38 import com.sun.enterprise.deployment.Descriptor;
39 import com.sun.enterprise.deployment.node.runtime.web.WebBundleRuntimeNode;
40 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
41 import com.sun.enterprise.deployment.xml.WebServicesTagNames;
42
43 import java.net.URL JavaDoc;
44 import java.net.MalformedURLException JavaDoc;
45
46 import com.sun.enterprise.deployment.util.DOLUtils;
47
48 /**
49  * This node is responsible for handling WebService runtime info
50  *
51  * @author Kenneth Saks
52  * @version
53  */

54 public class WebServiceRuntimeNode extends DeploymentDescriptorNode {
55
56     private WebService descriptor;
57
58     public Object JavaDoc getDescriptor() {
59         return descriptor;
60     }
61
62     /**
63      * receives notiification of the value for a particular tag
64      *
65      * @param element the xml element
66      * @param value it's associated value
67      */

68
69     public void setElementValue(XMLElement element, String JavaDoc value) {
70         if (WebServicesTagNames.WEB_SERVICE_DESCRIPTION_NAME.equals
71             (element.getQName())) {
72             BundleDescriptor parent;
73             if (getParentNode() instanceof WebBundleRuntimeNode) {
74                 parent = ((WebBundleRuntimeNode) getParentNode()).getWebBundleDescriptor();
75             } else {
76                 parent = (BundleDescriptor) getParentNode().getDescriptor();
77             }
78             WebServicesDescriptor webServices = parent.getWebServices();
79             descriptor = webServices.getWebServiceByName(value);
80         } else if( WebServicesTagNames.CLIENT_WSDL_PUBLISH_URL.equals
81                    (element.getQName()) ) {
82             if( descriptor == null ) {
83                 DOLUtils.getDefaultLogger().info
84                     ("Warning : WebService descriptor is null for "
85                      + "final wsdl url=" + value);
86                 return;
87             }
88             try {
89                 URL JavaDoc url = new URL JavaDoc(value);
90                 descriptor.setClientPublishUrl(url);
91             } catch(MalformedURLException JavaDoc mue) {
92                 DOLUtils.getDefaultLogger().log(Level.INFO,
93                   "Warning : Invalid final wsdl url=" + value, mue);
94             }
95         } else {
96             super.setElementValue(element, value);
97         }
98     }
99     
100     /**
101      * write the descriptor class to a DOM tree and return it
102      *
103      * @param parent node for the DOM tree
104      * @param node name for the descriptor
105      * @param the descriptor to write
106      * @return the DOM tree top node
107      */

108     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
109                                 WebService webService) {
110         Node JavaDoc webServiceNode =
111             super.writeDescriptor(parent, nodeName, webService);
112
113         appendTextChild(webServiceNode,
114                         WebServicesTagNames.WEB_SERVICE_DESCRIPTION_NAME,
115                         webService.getName());
116
117         if( webService.hasClientPublishUrl() ) {
118             URL JavaDoc url = webService.getClientPublishUrl();
119             appendTextChild(webServiceNode,
120                             WebServicesTagNames.CLIENT_WSDL_PUBLISH_URL,
121                             url.toExternalForm());
122         }
123
124         return webServiceNode;
125     }
126     
127     /**
128      * writes all the runtime information for the web services for a given
129      * bundle descriptor
130      *
131      * @param parent node to add the runtime xml info
132      * @param the bundle descriptor
133      */

134     public void writeWebServiceRuntimeInfo(Node JavaDoc parent,
135                                            BundleDescriptor bundle) {
136         WebServicesDescriptor webServices = bundle.getWebServices();
137         if( webServices != null ) {
138             for(Iterator iter = webServices.getWebServices().iterator();
139                 iter.hasNext();) {
140                 WebService next = (WebService) iter.next();
141                 if( next.hasClientPublishUrl() ) {
142                     writeDescriptor
143                         (parent, WebServicesTagNames.WEB_SERVICE, next);
144                 }
145             }
146         }
147     }
148     
149 }
150
Popular Tags