1 16 package org.apache.axis.deployment.wsdd; 17 18 import org.apache.axis.encoding.SerializationContext; 19 import org.apache.axis.utils.Messages; 20 import org.apache.axis.utils.XMLUtils; 21 import org.w3c.dom.Element ; 22 import org.xml.sax.helpers.AttributesImpl ; 23 24 import javax.xml.namespace.QName ; 25 import java.io.IOException ; 26 import java.util.HashMap ; 27 import java.util.Iterator ; 28 import java.util.Map ; 29 import java.util.Set ; 30 31 32 35 public class WSDDJAXRPCHandlerInfo 36 extends WSDDElement 37 { 38 private String _classname; 39 private Map _map; 40 private QName [] _headers; 41 42 45 public WSDDJAXRPCHandlerInfo() 46 { 47 } 48 49 54 public WSDDJAXRPCHandlerInfo(Element e) 55 throws WSDDException 56 { 57 super(e); 58 59 String classnameStr = e.getAttribute(ATTR_CLASSNAME); 60 if (classnameStr != null && !classnameStr.equals("")) { 61 _classname = classnameStr; 62 } 63 else 64 throw new WSDDException(Messages.getMessage("noClassNameAttr00")); 65 66 Element [] elements = getChildElements(e, ELEM_WSDD_PARAM); 67 68 _map = new HashMap (); 70 if (elements.length != 0) { 71 for (int i = 0; i < elements.length; i++) { 73 Element param = elements[i]; 74 String pname = param.getAttribute(ATTR_NAME); 75 String value = param.getAttribute(ATTR_VALUE); 76 _map.put(pname, value); 77 } 78 } 79 80 elements = getChildElements(e, ELEM_WSDD_JAXRPC_HEADER); 81 if (elements.length != 0) { 82 java.util.ArrayList headerList = new java.util.ArrayList (); 83 for (int i = 0; i < elements.length; i++) { 84 Element qElem = elements[i]; 85 String headerStr = qElem.getAttribute(ATTR_QNAME); 86 if (headerStr == null || headerStr.equals("")) 87 throw new WSDDException(Messages.getMessage("noValidHeader")); 88 89 QName headerQName = XMLUtils.getQNameFromString(headerStr, qElem); 90 if (headerQName != null) 91 headerList.add(headerQName); 92 } 93 QName [] headers = new QName [headerList.size()]; 94 _headers = (QName []) headerList.toArray(headers); 95 } 96 } 97 98 protected QName getElementName() 99 { 100 return QNAME_JAXRPC_HANDLERINFO; 101 } 102 103 public String getHandlerClassName() { 104 return _classname; 105 } 106 107 public void setHandlerClassName(String classname) { 108 _classname = classname; 109 } 110 111 public Map getHandlerMap() { 112 return _map; 113 } 114 115 public void setHandlerMap(Map map) { 116 _map = map; 117 } 118 119 public QName [] getHeaders() { 120 return _headers; 121 } 122 123 public void setHeaders(QName [] headers) { 124 _headers = headers; 125 } 126 127 public void writeToContext(SerializationContext context) 128 throws IOException 129 { 130 AttributesImpl attrs = new AttributesImpl (); 131 attrs.addAttribute("", ATTR_CLASSNAME, ATTR_CLASSNAME, 132 "CDATA", _classname); 133 context.startElement(WSDDConstants.QNAME_JAXRPC_HANDLERINFO, attrs); 134 135 Map ht = _map; 136 if (ht != null) { 137 Set keys= ht.keySet(); 138 Iterator iter = keys.iterator(); 139 while (iter.hasNext()) { 140 String name = (String ) iter.next(); 141 String value = (String ) ht.get(name); 142 attrs = new AttributesImpl (); 143 attrs.addAttribute("",ATTR_NAME, ATTR_NAME, "CDATA", name); 144 attrs.addAttribute("",ATTR_VALUE, ATTR_VALUE, "CDATA", value); 145 context.startElement(WSDDConstants.QNAME_PARAM,attrs); 146 context.endElement(); 147 } 148 } 149 150 if (_headers != null) { 151 for (int i=0 ; i < _headers.length ; i++) { 152 QName qname = _headers[i]; 153 attrs = new AttributesImpl (); 154 attrs.addAttribute("",ATTR_QNAME,ATTR_QNAME,"CDATA",context.qName2String(qname)); 155 context.startElement(WSDDConstants.QNAME_JAXRPC_HEADER,attrs); 156 context.endElement(); 157 } 158 } 159 160 context.endElement(); 161 } 162 163 } 164 | Popular Tags |