1 23 24 package com.sun.enterprise.deployment.node; 25 26 import java.util.ArrayList ; 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 import java.util.logging.Level ; 31 import java.util.Map ; 32 import java.util.Set ; 33 import org.w3c.dom.Document ; 34 import org.w3c.dom.Node ; 35 36 import java.io.IOException ; 37 import java.io.InputStream ; 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 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 SCHEMA_ID = "javaee_web_services_1_2.xsd"; 63 public final static String SPEC_VERSION = "1.2"; 64 private static List <String > 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 81 public String getDocType() { 82 return null; 83 } 84 85 88 public String getSystemID() { 89 return SCHEMA_ID; 90 } 91 92 95 public List <String > getSystemIDs() { 96 if (systemIDs != null) { 97 return systemIDs; 98 } 99 100 systemIDs = new ArrayList <String >(); 101 systemIDs.add(SCHEMA_ID); 102 return systemIDs; 103 } 104 105 108 protected String getSchemaURL() { 109 return WebServicesTagNames.IBM_NAMESPACE + "/" + getSystemID(); 110 } 111 112 115 protected XMLElement getXMLRootTag() { 116 return ROOT_ELEMENT; 117 } 118 119 125 public void setElementValue(XMLElement element, String value) { 126 if (TagNames.VERSION.equals(element.getQName())) { 127 bundleDescriptor.getWebServices().setSpecVersion(value); 128 } else super.setElementValue(element, value); 129 } 130 131 137 public void addDescriptor(Object descriptor) { 138 WebServicesDescriptor webServicesDesc = 139 bundleDescriptor.getWebServices(); 140 WebService webService = (WebService) descriptor; 141 webServicesDesc.addWebService(webService); 142 143 for(Iterator 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 156 public Object getDescriptor() { 157 return bundleDescriptor; 158 } 159 160 167 public Node writeDescriptor(Node parent, Descriptor descriptor) { 168 Node topNode = parent; 169 if (parent instanceof Document ) { 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 185 public String getSpecVersion() { 186 return SPEC_VERSION; 187 } 188 189 } 190 191 | Popular Tags |