1 23 24 package com.sun.enterprise.deployment.node; 25 26 import java.util.Iterator ; 27 import java.util.Map ; 28 import java.util.logging.Level ; 29 30 import java.util.List ; 31 import org.w3c.dom.Node ; 32 import org.xml.sax.Attributes ; 33 34 import javax.xml.namespace.QName ; 35 36 import com.sun.enterprise.deployment.util.DOLUtils; 37 import com.sun.enterprise.deployment.WebServiceHandler; 38 import com.sun.enterprise.deployment.NameValuePairDescriptor; 39 import com.sun.enterprise.deployment.xml.TagNames; 40 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 41 42 47 public class WebServiceHandlerNode extends DisplayableComponentNode { 48 49 private final static XMLElement tag = 50 new XMLElement(WebServicesTagNames.HANDLER); 51 52 private NameValuePairDescriptor initParam = null; 53 54 public WebServiceHandlerNode() { 55 super(); 56 } 57 58 61 protected XMLElement getXMLRootTag() { 62 return tag; 63 } 64 65 71 protected Map getDispatchTable() { 72 Map table = super.getDispatchTable(); 73 table.put(WebServicesTagNames.SOAP_ROLE, "addSoapRole"); 74 table.put(WebServicesTagNames.HANDLER_NAME, "setHandlerName"); 75 table.put(WebServicesTagNames.HANDLER_CLASS, "setHandlerClass"); 76 table.put(WebServicesTagNames.HANDLER_PORT_NAME, "addPortName"); 77 return table; 78 } 79 80 86 public void setElementValue(XMLElement element, String value) { 87 String qname = element.getQName(); 88 WebServiceHandler handler = (WebServiceHandler) getDescriptor(); 89 if (WebServicesTagNames.INIT_PARAM_NAME.equals(qname)) { 90 initParam = new NameValuePairDescriptor(); 91 initParam.setName(value); 92 } else if (WebServicesTagNames.INIT_PARAM_VALUE.equals(qname)) { 93 initParam.setValue(value); 94 handler.addInitParam(initParam); 95 } else if (TagNames.DESCRIPTION.equals(qname)) { 96 if( initParam != null ) { 97 initParam.setDescription(value); 99 initParam = null; 100 } else { 101 super.setElementValue(element, value); 103 } 104 } else if (WebServicesTagNames.SOAP_HEADER.equals(qname) ) { 105 String prefix = getPrefixFromQName(value); 106 String localPart = getLocalPartFromQName(value); 107 String namespaceUri = resolvePrefix(element, prefix); 108 109 if( namespaceUri == null) { 110 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure", 111 new Object [] {prefix , handler.getHandlerName()}); 112 } else { 113 QName soapHeader = new QName (namespaceUri, localPart); 114 handler.addSoapHeader(soapHeader); 115 } 116 117 } else super.setElementValue(element, value); 118 } 119 120 129 public Node writeDescriptor(Node parent, String nodeName, 130 WebServiceHandler handler) { 131 Node wshNode = super.writeDescriptor(parent, nodeName, handler); 132 133 writeDisplayableComponentInfo(wshNode, handler); 134 appendTextChild(wshNode, 135 WebServicesTagNames.HANDLER_NAME, 136 handler.getHandlerName()); 137 138 appendTextChild(wshNode, 139 WebServicesTagNames.HANDLER_CLASS, 140 handler.getHandlerClass()); 141 142 for(Iterator iter = handler.getInitParams().iterator();iter.hasNext();){ 143 NameValuePairDescriptor next = (NameValuePairDescriptor)iter.next(); 144 Node initParamNode = 145 appendChild(wshNode, WebServicesTagNames.INIT_PARAM); 146 appendTextChild(initParamNode, WebServicesTagNames.INIT_PARAM_NAME, 147 next.getName()); 148 appendTextChild(initParamNode, WebServicesTagNames.INIT_PARAM_VALUE, 149 next.getValue()); 150 } 151 152 for(Iterator iter = handler.getSoapHeaders().iterator(); 153 iter.hasNext();) { 154 QName next = (QName ) iter.next(); 155 appendQNameChild(WebServicesTagNames.SOAP_HEADER, wshNode, 158 next.getNamespaceURI(), next.getLocalPart(), null); 159 } 160 161 for(Iterator iter = handler.getSoapRoles().iterator(); iter.hasNext();){ 162 String next = (String ) iter.next(); 163 appendTextChild(wshNode, WebServicesTagNames.SOAP_ROLE, next); 164 } 165 166 for(Iterator iter = handler.getPortNames().iterator(); iter.hasNext();){ 167 String next = (String ) iter.next(); 168 appendTextChild(wshNode, WebServicesTagNames.HANDLER_PORT_NAME, 169 next); 170 } 171 172 return wshNode; 173 } 174 175 public void writeWebServiceHandlers(Node parent, List handlerChain) { 176 for(Iterator iter = handlerChain.iterator(); iter.hasNext();) { 177 WebServiceHandler next = (WebServiceHandler) iter.next(); 178 writeDescriptor(parent, WebServicesTagNames.HANDLER, next); 179 } 180 } 181 182 } 183 | Popular Tags |