1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.jboss.axis.encoding.SerializationContext; 58 import org.jboss.axis.utils.Messages; 59 import org.jboss.axis.utils.XMLUtils; 60 import org.w3c.dom.Element ; 61 import org.xml.sax.helpers.AttributesImpl ; 62 63 import javax.xml.namespace.QName ; 64 import java.io.IOException ; 65 import java.util.HashMap ; 66 import java.util.Iterator ; 67 import java.util.Map ; 68 import java.util.Set ; 69 70 71 74 public class WSDDJAXRPCHandlerInfo 75 extends WSDDElement 76 { 77 private String _classname; 78 private Map _map; 79 private QName [] _headers; 80 81 84 public WSDDJAXRPCHandlerInfo() 85 { 86 } 87 88 92 public WSDDJAXRPCHandlerInfo(Element e) 93 throws WSDDException 94 { 95 super(e); 96 97 String classnameStr = e.getAttribute(ATTR_CLASSNAME); 98 if (classnameStr != null && !classnameStr.equals("")) 99 { 100 _classname = classnameStr; 101 } 102 else 103 throw new WSDDException(Messages.getMessage("noClassNameAttr00")); 104 105 Element [] elements = getChildElements(e, ELEM_WSDD_PARAM); 106 if (elements.length != 0) 107 { 108 _map = new HashMap (); 109 110 for (int i = 0; i < elements.length; i++) 112 { 113 Element param = elements[i]; 114 String pname = param.getAttribute(ATTR_NAME); 115 String value = param.getAttribute(ATTR_VALUE); 116 _map.put(pname, value); 117 } 118 } 119 120 elements = getChildElements(e, ELEM_WSDD_JAXRPC_HEADER); 121 if (elements.length != 0) 122 { 123 java.util.ArrayList headerList = new java.util.ArrayList (); 124 for (int i = 0; i < elements.length; i++) 125 { 126 Element qElem = elements[i]; 127 String headerStr = qElem.getAttribute(ATTR_QNAME); 128 if (headerStr == null || headerStr.equals("")) 129 throw new WSDDException(Messages.getMessage("noValidHeader")); 130 131 QName headerQName = XMLUtils.getQNameFromString(headerStr, qElem); 132 if (headerQName != null) 133 headerList.add(headerQName); 134 } 135 QName [] headers = new QName [headerList.size()]; 136 _headers = (QName [])headerList.toArray(headers); 137 } 138 } 139 140 protected QName getElementName() 141 { 142 return QNAME_JAXRPC_HANDLERINFO; 143 } 144 145 public String getHandlerClassName() 146 { 147 return _classname; 148 } 149 150 public void setHandlerClassName(String classname) 151 { 152 _classname = classname; 153 } 154 155 public Map getHandlerMap() 156 { 157 return _map; 158 } 159 160 public void setHandlerMap(Map map) 161 { 162 _map = map; 163 } 164 165 public QName [] getHeaders() 166 { 167 return _headers; 168 } 169 170 public void setHeaders(QName [] headers) 171 { 172 _headers = headers; 173 } 174 175 public void writeToContext(SerializationContext context) 176 throws IOException 177 { 178 AttributesImpl attrs = new AttributesImpl (); 179 attrs.addAttribute("", ATTR_CLASSNAME, ATTR_CLASSNAME, 180 "CDATA", _classname); 181 context.startElement(WSDDConstants.QNAME_JAXRPC_HANDLERINFO, attrs); 182 183 Map ht = _map; 184 if (ht != null) 185 { 186 Set keys = ht.keySet(); 187 Iterator iter = keys.iterator(); 188 while (iter.hasNext()) 189 { 190 String name = (String )iter.next(); 191 String value = (String )ht.get(name); 192 attrs = new AttributesImpl (); 193 attrs.addAttribute("", ATTR_NAME, ATTR_NAME, "CDATA", name); 194 attrs.addAttribute("", ATTR_VALUE, ATTR_VALUE, "CDATA", value); 195 context.startElement(WSDDConstants.QNAME_PARAM, attrs); 196 context.endElement(); 197 } 198 } 199 200 if (_headers != null) 201 { 202 for (int i = 0; i < _headers.length; i++) 203 { 204 QName qname = _headers[i]; 205 attrs = new AttributesImpl (); 206 attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME, "CDATA", context.qName2String(qname)); 207 context.startElement(WSDDConstants.QNAME_JAXRPC_HEADER, attrs); 208 context.endElement(); 209 } 210 } 211 212 context.endElement(); 213 } 214 215 } 216 | Popular Tags |