1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.jboss.axis.description.FaultDesc; 58 import org.jboss.axis.description.OperationDesc; 59 import org.jboss.axis.description.ParameterDesc; 60 import org.jboss.axis.description.ServiceDesc; 61 import org.jboss.axis.encoding.SerializationContext; 62 import org.jboss.axis.utils.JavaUtils; 63 import org.jboss.axis.utils.XMLUtils; 64 import org.w3c.dom.Element ; 65 import org.xml.sax.helpers.AttributesImpl ; 66 67 import javax.xml.namespace.QName ; 68 import java.io.IOException ; 69 import java.util.ArrayList ; 70 import java.util.Iterator ; 71 72 80 public class WSDDOperation extends WSDDElement 81 { 82 85 OperationDesc desc = new OperationDesc(); 86 87 90 public WSDDOperation(OperationDesc desc) 91 { 92 this.desc = desc; 93 } 94 95 102 public WSDDOperation(Element e, ServiceDesc parent) 103 throws WSDDException 104 { 105 super(e); 106 107 desc.setParent(parent); 108 desc.setName(e.getAttribute(ATTR_NAME)); 109 desc.setOneWay(JavaUtils.isTrueExplicitly(e.getAttribute(ATTR_ONEWAY))); 110 111 String qNameStr = e.getAttribute(ATTR_QNAME); 112 if (qNameStr != null && !qNameStr.equals("")) 113 desc.setElementQName(XMLUtils.getQNameFromString(qNameStr, e)); 114 115 String retQNameStr = e.getAttribute(ATTR_RETQNAME); 116 if (retQNameStr != null && !retQNameStr.equals("")) 117 desc.setReturnQName(XMLUtils.getQNameFromString(retQNameStr, e)); 118 119 String retTypeStr = e.getAttribute(ATTR_RETTYPE); 120 if (retTypeStr != null && !retTypeStr.equals("")) 121 desc.setReturnType(XMLUtils.getQNameFromString(retTypeStr, e)); 122 123 String retHStr = e.getAttribute(ATTR_RETHEADER); 124 if (retHStr != null) 125 { 126 desc.setReturnHeader(JavaUtils.isTrueExplicitly(retHStr)); 127 } 128 129 Element [] parameters = getChildElements(e, ELEM_WSDD_PARAM); 130 for (int i = 0; i < parameters.length; i++) 131 { 132 Element paramEl = parameters[i]; 133 WSDDParameter parameter = new WSDDParameter(paramEl, desc); 134 desc.addParameter(parameter.getParameter()); 135 } 136 137 Element [] faultElems = getChildElements(e, ELEM_WSDD_FAULT); 138 for (int i = 0; i < faultElems.length; i++) 139 { 140 Element faultElem = faultElems[i]; 141 WSDDFault fault = new WSDDFault(faultElem); 142 desc.addFault(fault.getFaultDesc()); 143 } 144 } 145 146 149 public void writeToContext(SerializationContext context) 150 throws IOException 151 { 152 AttributesImpl attrs = new AttributesImpl (); 153 154 if (desc.getReturnQName() != null) 155 { 156 attrs.addAttribute("", ATTR_RETQNAME, ATTR_RETQNAME, 157 "CDATA", 158 context.qName2String(desc.getReturnQName())); 159 } 160 161 if (desc.getReturnType() != null) 162 { 163 attrs.addAttribute("", ATTR_RETTYPE, ATTR_RETTYPE, 164 "CDATA", 165 context.qName2String(desc.getReturnType())); 166 } 167 if (desc.isReturnHeader()) 168 { 169 attrs.addAttribute("", ATTR_RETHEADER, ATTR_RETHEADER, 170 "CDATA", "true"); 171 } 172 173 if (desc.getName() != null) 174 { 175 attrs.addAttribute("", ATTR_NAME, ATTR_NAME, "CDATA", desc.getName()); 176 } 177 178 if (desc.getElementQName() != null) 179 { 180 attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME, 181 "CDATA", 182 context.qName2String(desc.getElementQName())); 183 } 184 185 context.startElement(getElementName(), attrs); 186 187 ArrayList params = desc.getParameters(); 188 for (Iterator i = params.iterator(); i.hasNext();) 189 { 190 ParameterDesc parameterDesc = (ParameterDesc)i.next(); 191 WSDDParameter p = new WSDDParameter(parameterDesc); 192 p.writeToContext(context); 193 } 194 195 ArrayList faults = desc.getFaults(); 196 if (faults != null) 197 { 198 for (Iterator i = faults.iterator(); i.hasNext();) 199 { 200 FaultDesc faultDesc = (FaultDesc)i.next(); 201 WSDDFault f = new WSDDFault(faultDesc); 202 f.writeToContext(context); 203 } 204 } 205 206 context.endElement(); 207 } 208 209 protected QName getElementName() 210 { 211 return QNAME_OPERATION; 212 } 213 214 public OperationDesc getOperationDesc() 215 { 216 return desc; 217 } 218 } 219 | Popular Tags |