1 23 24 29 30 package com.sun.enterprise.deployment.node; 31 32 import java.util.*; 33 import java.util.logging.Level ; 34 import org.w3c.dom.Node ; 35 36 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 37 import com.sun.enterprise.deployment.xml.TagNames; 38 import com.sun.enterprise.deployment.ServiceReferenceDescriptor; 39 import com.sun.enterprise.deployment.ServiceRefPortInfo; 40 import com.sun.enterprise.deployment.InjectionTarget; 41 import com.sun.enterprise.deployment.util.DOLUtils; 42 import javax.xml.namespace.QName ; 43 44 50 public class ServiceReferenceNode extends DisplayableComponentNode { 51 private String serviceEndpointInterface = null; 53 private ServiceRefPortInfo portInfo = null; 54 55 56 public ServiceReferenceNode() { 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 registerElementHandler 65 (new XMLElement(TagNames.INJECTION_TARGET), 66 InjectionTargetNode.class, "addInjectionTarget"); 67 } 68 69 76 protected Map getDispatchTable() { 77 Map table = super.getDispatchTable(); 78 table.put(WebServicesTagNames.SERVICE_REF_NAME, "setName"); 79 table.put(WebServicesTagNames.SERVICE_INTERFACE, "setServiceInterface"); 80 table.put(WebServicesTagNames.WSDL_FILE, "setWsdlFileUri"); 81 table.put(WebServicesTagNames.JAXRPC_MAPPING_FILE, "setMappingFileUri"); 82 table.put(WebServicesTagNames.MAPPED_NAME, "setMappedName"); 83 table.put(WebServicesTagNames.SERVICE_REF_TYPE, "setInjectionTargetType"); 84 return table; 85 } 86 87 private ServiceReferenceDescriptor getServiceReferenceDescriptor() { 88 return (ServiceReferenceDescriptor) getDescriptor(); 89 } 90 91 97 public void setElementValue(XMLElement element, String value) { 98 String qname = element.getQName(); 99 if (WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE.equals(qname)) { 100 portInfo = getServiceReferenceDescriptor().getPortInfoBySEI(value); 101 if( portInfo == null ) { 102 portInfo = getServiceReferenceDescriptor(). 103 addContainerManagedPort(value); 104 } 105 } else if( WebServicesTagNames.SERVICE_QNAME.equals(qname) ) { 106 String prefix = getPrefixFromQName(value); 107 String localPart = getLocalPartFromQName(value); 108 String namespaceUri = resolvePrefix(element, prefix); 109 if( namespaceUri == null) { 110 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure", 111 new Object [] { prefix , getServiceReferenceDescriptor().getName()}); 112 } else { 113 QName serviceName = new QName (namespaceUri, localPart); 114 getServiceReferenceDescriptor().setServiceName 115 (serviceName, prefix); 116 } 117 } else if(WebServicesTagNames.ENABLE_MTOM.equals(qname)) { 118 portInfo.setMtomEnabled(value); 119 } else if( WebServicesTagNames.PORT_COMPONENT_LINK.equals(qname) ) { 120 portInfo.setPortComponentLinkName(value); 123 portInfo = null; 124 } else { 125 super.setElementValue(element, value); 126 } 127 } 128 129 138 public Node writeDescriptor(Node parent, String nodeName, 139 ServiceReferenceDescriptor descriptor) { 140 Node serviceRefNode = 141 super.writeDescriptor(parent, nodeName, descriptor); 142 143 writeDisplayableComponentInfo(serviceRefNode, descriptor); 144 appendTextChild(serviceRefNode, WebServicesTagNames.SERVICE_REF_NAME, 145 descriptor.getName()); 146 appendTextChild(serviceRefNode, WebServicesTagNames.SERVICE_INTERFACE, 147 descriptor.getServiceInterface()); 148 appendTextChild(serviceRefNode, WebServicesTagNames.SERVICE_REF_TYPE, 149 descriptor.getInjectionTargetType()); 150 appendTextChild(serviceRefNode, WebServicesTagNames.WSDL_FILE, 151 descriptor.getWsdlFileUri()); 152 appendTextChild(serviceRefNode, WebServicesTagNames.JAXRPC_MAPPING_FILE, 153 descriptor.getMappingFileUri()); 154 155 if( descriptor.hasServiceName() ) { 156 QName serviceName = descriptor.getServiceName(); 157 appendQNameChild(WebServicesTagNames.SERVICE_QNAME, serviceRefNode, 158 serviceName.getNamespaceURI(), 159 serviceName.getLocalPart(), 160 descriptor.getServiceNameNamespacePrefix()); 161 } 162 163 for(Iterator iter = descriptor.getPortsInfo().iterator(); 164 iter.hasNext();) { 165 ServiceRefPortInfo next = (ServiceRefPortInfo) iter.next(); 166 if( next.isContainerManaged() ) { 167 String serviceEndpointInterface = 168 next.getServiceEndpointInterface(); 169 Node portComponentRefNode = appendChild 170 (serviceRefNode, WebServicesTagNames.PORT_COMPONENT_REF); 171 appendTextChild(portComponentRefNode, 172 WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE, 173 serviceEndpointInterface); 174 appendTextChild(portComponentRefNode, 175 WebServicesTagNames.ENABLE_MTOM, 176 next.getMtomEnabled()); 177 appendTextChild(portComponentRefNode, 178 WebServicesTagNames.PORT_COMPONENT_LINK, 179 next.getPortComponentLinkName()); 180 } 181 } 182 183 WebServiceHandlerNode handlerNode = new WebServiceHandlerNode(); 184 handlerNode.writeWebServiceHandlers(serviceRefNode, 185 descriptor.getHandlers()); 186 187 WebServiceHandlerChainNode handlerChainNode = 188 new WebServiceHandlerChainNode(); 189 handlerChainNode.writeWebServiceHandlerChains(serviceRefNode, 190 descriptor.getHandlerChain()); 191 192 appendTextChild(serviceRefNode, WebServicesTagNames.MAPPED_NAME, 193 descriptor.getMappedName()); 194 195 if (descriptor.isInjectable()) { 196 InjectionTargetNode ijNode = new InjectionTargetNode(); 197 for (InjectionTarget target : descriptor.getInjectionTargets()) { 198 ijNode.writeDescriptor(serviceRefNode, TagNames.INJECTION_TARGET, target); 199 } 200 } 201 202 return serviceRefNode; 203 } 204 205 } 206 | Popular Tags |