1 26 27 package org.objectweb.jonas_ws.wsgen.generator.axis; 28 29 import java.lang.reflect.Method ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 import java.util.Vector ; 33 34 import javax.wsdl.BindingFault; 35 import javax.wsdl.BindingOperation; 36 import javax.wsdl.Definition; 37 import javax.wsdl.Port; 38 import javax.wsdl.Service; 39 import javax.wsdl.extensions.ExtensibilityElement; 40 import javax.wsdl.extensions.soap.SOAPBinding; 41 import javax.wsdl.extensions.soap.SOAPBody; 42 import javax.wsdl.extensions.soap.SOAPFault; 43 import javax.wsdl.extensions.soap.SOAPOperation; 44 import javax.xml.namespace.QName ; 45 46 import org.objectweb.jonas_ejb.deployment.api.SessionStatelessDesc; 47 48 import org.objectweb.jonas_lib.deployment.api.HandlerDesc; 49 50 import org.objectweb.jonas_ws.deployment.api.PortComponentDesc; 51 import org.objectweb.jonas_ws.deployment.api.SSBPortComponentDesc; 52 53 58 public class VcPortComponent { 59 60 61 private String name; 62 63 64 private VcBean bean = null; 65 66 67 private static final String SEP = ","; 68 69 70 private String methods = null; 71 72 73 private Vector handlers = new Vector (); 74 75 76 private String jaxRpcClassName; 77 78 79 private String wsdlFilename; 80 81 84 private static final String DOCUMENT_STYLE = "document"; 85 86 89 private String style = null; 90 91 94 private String use = null; 95 96 99 private String namespace = null; 100 101 104 public static final String NS_URI_SOAP = "http://schemas.xmlsoap.org/wsdl/soap/"; 105 106 109 private static final QName SOAP_BINDING_QNAME = new QName (NS_URI_SOAP, "binding"); 110 111 114 private static final QName SOAP_OPERATION_QNAME = new QName (NS_URI_SOAP, "operation"); 115 116 119 private static final QName SOAP_BODY_QNAME = new QName (NS_URI_SOAP, "body"); 120 121 124 private static final QName SOAP_FAULT_QNAME = new QName (NS_URI_SOAP, "fault"); 125 126 132 public VcPortComponent(PortComponentDesc pcd, String wsdl) { 133 134 name = pcd.getServiceName(); 136 137 wsdlFilename = wsdl; 138 139 if (pcd.hasBeanImpl()) { 141 SessionStatelessDesc ssb = ((SSBPortComponentDesc) pcd).getSessionStatelessDesc(); 143 bean = new VcBean(ssb); 144 } else { 145 jaxRpcClassName = pcd.getSIBClassname(); 146 } 147 Method [] m = pcd.getServiceEndpointInterface().getMethods(); 149 for (int i = 0; i < m.length; i++) { 150 if (methods != null) { 151 methods += SEP; 152 } else { 153 methods = ""; 154 } 155 methods += m[i].getName(); 156 } 157 158 Definition def = pcd.getServiceDesc().getWSDL().getDefinition(); 160 boolean portFound = false; 161 for (Iterator i = def.getServices().keySet().iterator(); i.hasNext() && !portFound;) { 162 Service s = def.getService((QName ) i.next()); 163 Port p = s.getPort(pcd.getQName().getLocalPart()); 164 if (p != null) { 165 portFound = true; 167 168 style = getStyle(p); 170 171 use = getUse(p); 173 } 174 } 175 namespace = def.getTargetNamespace(); 176 177 List hs = pcd.getHandlers(); 179 for (Iterator itH = hs.iterator(); itH.hasNext();) { 180 HandlerDesc hd = (HandlerDesc) itH.next(); 181 handlers.add(new VcHandler(hd)); 182 } 183 184 } 185 186 190 private static String getUse(Port p) { 191 String use = null; 192 193 List ops = p.getBinding().getBindingOperations(); 199 for (Iterator j = ops.iterator(); j.hasNext() && (use == null);) { 200 BindingOperation bop = (BindingOperation) j.next(); 201 202 List inputExt = bop.getBindingInput().getExtensibilityElements(); 204 for (Iterator k = inputExt.iterator(); k.hasNext() && (use == null);) { 205 ExtensibilityElement ext = (ExtensibilityElement) k.next(); 206 if (ext.getElementType().equals(SOAP_BODY_QNAME)) { 207 SOAPBody sb = (SOAPBody) ext; 208 use = sb.getUse(); 209 } 210 } 211 212 List outputExt = bop.getBindingOutput().getExtensibilityElements(); 214 for (Iterator k = outputExt.iterator(); k.hasNext() && (use == null);) { 215 ExtensibilityElement ext = (ExtensibilityElement) k.next(); 216 if (ext.getElementType().equals(SOAP_BODY_QNAME)) { 217 SOAPBody sb = (SOAPBody) ext; 218 use = sb.getUse(); 219 } 220 } 221 222 for (Iterator k = bop.getBindingFaults().keySet().iterator(); k.hasNext() && (use == null);) { 224 BindingFault bf = bop.getBindingFault((String ) k.next()); 225 226 List faultExt = bf.getExtensibilityElements(); 228 for (Iterator i = faultExt.iterator(); i.hasNext() && (use == null);) { 229 ExtensibilityElement ext = (ExtensibilityElement) i.next(); 230 if (ext.getElementType().equals(SOAP_FAULT_QNAME)) { 231 SOAPFault sf = (SOAPFault) ext; 232 use = sf.getUse(); 233 } 234 } 235 } 236 } 237 239 return use; 240 } 241 242 246 private static String getStyle(Port p) { 247 String style = null; 248 249 List bindingOps = p.getBinding().getBindingOperations(); 251 for (Iterator i = bindingOps.iterator(); i.hasNext() && (style == null);) { 252 253 BindingOperation bop = (BindingOperation) i.next(); 254 List extElements = bop.getExtensibilityElements(); 256 for (Iterator j = extElements.iterator(); j.hasNext();) { 257 ExtensibilityElement ext = (ExtensibilityElement) j.next(); 258 if (ext.getElementType().equals(SOAP_OPERATION_QNAME)) { 259 260 SOAPOperation sop = (SOAPOperation) ext; 262 style = sop.getStyle(); 263 } 264 } 265 } 266 267 List soapElements = p.getBinding().getExtensibilityElements(); 269 for (Iterator i = soapElements.iterator(); i.hasNext() && (style == null);) { 270 271 ExtensibilityElement ext = (ExtensibilityElement) i.next(); 272 if (ext.getElementType().equals(SOAP_BINDING_QNAME)) { 273 274 SOAPBinding soapb = (SOAPBinding) ext; 276 style = soapb.getStyle(); 277 } 278 279 } 280 281 if (style == null) { 282 style = DOCUMENT_STYLE; 283 } 284 285 return style; 286 } 287 288 294 public VcPortComponent(String name, List hrs) { 295 296 this.name = name; 298 299 for (Iterator itH = hrs.iterator(); itH.hasNext();) { 301 HandlerDesc hr = (HandlerDesc) itH.next(); 302 handlers.add(new VcHandler(hr)); 303 } 304 305 } 306 307 310 public String getName() { 311 return name; 312 } 313 314 317 public VcBean getBean() { 318 return bean; 319 } 320 321 324 public String getWSDLFilename() { 325 return wsdlFilename; 326 } 327 328 331 public String getMethods() { 332 return methods; 333 } 334 335 338 public Vector getHandlers() { 339 return handlers; 340 } 341 342 345 public String getJaxRpcClassName() { 346 return jaxRpcClassName; 347 } 348 349 352 public String getStyle() { 353 return style; 354 } 355 356 359 public String getUse() { 360 return use; 361 } 362 363 366 public String getNamespace() { 367 return namespace; 368 } 369 } | Popular Tags |