1 23 24 29 30 package com.sun.enterprise.deployment.node; 31 32 import java.util.Map ; 33 import java.util.HashMap ; 34 import java.util.Iterator ; 35 import org.w3c.dom.Node ; 36 import org.w3c.dom.Element ; 37 38 import java.util.logging.Level ; 39 import javax.xml.namespace.QName ; 40 41 import com.sun.enterprise.deployment.util.DOLUtils; 42 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 43 import com.sun.enterprise.deployment.WebServiceEndpoint; 44 45 50 public class WebServiceEndpointNode extends DisplayableComponentNode { 51 52 private final static XMLElement tag = 53 new XMLElement(WebServicesTagNames.PORT_COMPONENT); 54 55 56 public WebServiceEndpointNode() { 57 super(); 58 registerElementHandler 59 (new XMLElement(WebServicesTagNames.HANDLER), 60 WebServiceHandlerNode.class, "addHandler"); 61 registerElementHandler 62 (new XMLElement(WebServicesTagNames.HANDLER_CHAIN), 63 WebServiceHandlerChainNode.class, "addHandlerChain"); 64 } 65 66 69 protected XMLElement getXMLRootTag() { 70 return tag; 71 } 72 73 79 protected Map getDispatchTable() { 80 Map table = super.getDispatchTable(); 81 table.put(WebServicesTagNames.PORT_COMPONENT_NAME, "setEndpointName"); 82 table.put(WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE, 83 "setServiceEndpointInterface"); 84 table.put(WebServicesTagNames.PROTOCOL_BINDING, "setProtocolBinding"); 85 table.put(WebServicesTagNames.ENABLE_MTOM, "setMtomEnabled"); 86 return table; 87 } 88 89 95 public void setElementValue(XMLElement element, String value) { 96 String elementName = element.getQName(); 97 WebServiceEndpoint endpoint = (WebServiceEndpoint) getDescriptor(); 98 if (WebServicesTagNames.EJB_LINK.equals(elementName)) { 99 endpoint.setEjbLink(value); 100 } else if (WebServicesTagNames.SERVLET_LINK.equals(elementName)) { 101 endpoint.setWebComponentLink(value); 102 } else if (WebServicesTagNames.WSDL_PORT.equals(elementName)) { 103 String prefix = getPrefixFromQName(value); 104 String localPart = getLocalPartFromQName(value); 105 String namespaceUri = resolvePrefix(element, prefix); 106 if( namespaceUri == null) { 107 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure", 108 new Object [] {prefix , value }); 109 } else { 110 QName wsdlPort = new QName (namespaceUri, localPart); 111 endpoint.setWsdlPort(wsdlPort, prefix); 112 } 113 } else if(WebServicesTagNames.WSDL_SERVICE.equals(elementName)) { 114 String prefix = getPrefixFromQName(value); 115 String localPart = getLocalPartFromQName(value); 116 String namespaceUri = resolvePrefix(element, prefix); 117 if( namespaceUri == null) { 118 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure", 119 new Object [] {prefix , value }); 120 } else { 121 QName wsdlSvc = new QName (namespaceUri, localPart); 122 endpoint.setWsdlService(wsdlSvc, prefix); 123 } 124 } else super.setElementValue(element, value); 125 } 126 127 136 public Node writeDescriptor(Node parent, String nodeName, 137 WebServiceEndpoint descriptor) { 138 Node wseNode = super.writeDescriptor(parent, nodeName, descriptor); 139 140 writeDisplayableComponentInfo(wseNode, descriptor); 141 142 appendTextChild(wseNode, 143 WebServicesTagNames.PORT_COMPONENT_NAME, 144 descriptor.getEndpointName()); 145 146 QName wsdlService = descriptor.getWsdlService(); 147 if((wsdlService!=null) && 148 (wsdlService.getLocalPart().length() != 0)) { 149 appendQNameChild(WebServicesTagNames.WSDL_SERVICE, wseNode, 150 wsdlService.getNamespaceURI(), wsdlService.getLocalPart(), 151 descriptor.getWsdlServiceNamespacePrefix()); 152 } 153 154 QName wsdlPort = descriptor.getWsdlPort(); 155 if((wsdlPort!=null) && 156 (wsdlPort.getLocalPart().length() != 0)) { 157 appendQNameChild(WebServicesTagNames.WSDL_PORT, wseNode, 158 wsdlPort.getNamespaceURI(), wsdlPort.getLocalPart(), 159 descriptor.getWsdlPortNamespacePrefix()); 160 } 161 162 appendTextChild(wseNode, 163 WebServicesTagNames.ENABLE_MTOM, 164 descriptor.getMtomEnabled()); 165 if(descriptor.hasUserSpecifiedProtocolBinding()) { 166 appendTextChild(wseNode, 167 WebServicesTagNames.PROTOCOL_BINDING, 168 descriptor.getProtocolBinding()); 169 } 170 171 appendTextChild(wseNode, 172 WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE, 173 descriptor.getServiceEndpointInterface()); 174 175 if( descriptor.implementedByWebComponent() ) { 176 Node linkNode = 177 appendChild(wseNode, WebServicesTagNames.SERVICE_IMPL_BEAN); 178 appendTextChild(linkNode, WebServicesTagNames.SERVLET_LINK, 179 descriptor.getWebComponentLink()); 180 } else if( descriptor.implementedByEjbComponent() ) { 181 Node linkNode = 182 appendChild(wseNode, WebServicesTagNames.SERVICE_IMPL_BEAN); 183 appendTextChild(linkNode, WebServicesTagNames.EJB_LINK, 184 descriptor.getEjbLink()); 185 } else { 186 DOLUtils.getDefaultLogger().log 187 (Level.INFO, "Warning : Web service endpoint " + 188 descriptor.getEndpointName() + " is not tied to a component"); 189 } 190 191 WebServiceHandlerNode handlerNode = new WebServiceHandlerNode(); 192 handlerNode.writeWebServiceHandlers(wseNode, 193 descriptor.getHandlers()); 194 195 WebServiceHandlerChainNode handlerChainNode = new WebServiceHandlerChainNode(); 196 handlerChainNode.writeWebServiceHandlerChains(wseNode, descriptor.getHandlerChain()); 197 return wseNode; 198 } 199 } 200 | Popular Tags |