src/share/jaxws_classes/com/sun/tools/internal/ws/processor/generator/SeiGenerator.java

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
permissions
-rw-r--r--

8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com

ohair@286 1 /*
alanb@368 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
ohair@286 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286 4 *
ohair@286 5 * This code is free software; you can redistribute it and/or modify it
ohair@286 6 * under the terms of the GNU General Public License version 2 only, as
ohair@286 7 * published by the Free Software Foundation. Oracle designates this
ohair@286 8 * particular file as subject to the "Classpath" exception as provided
ohair@286 9 * by Oracle in the LICENSE file that accompanied this code.
ohair@286 10 *
ohair@286 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286 14 * version 2 for more details (a copy is included in the LICENSE file that
ohair@286 15 * accompanied this code).
ohair@286 16 *
ohair@286 17 * You should have received a copy of the GNU General Public License version
ohair@286 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286 20 *
ohair@286 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286 22 * or visit www.oracle.com if you need additional information or have any
ohair@286 23 * questions.
ohair@286 24 */
ohair@286 25
ohair@286 26 package com.sun.tools.internal.ws.processor.generator;
ohair@286 27
ohair@286 28 import com.sun.codemodel.internal.*;
ohair@286 29 import com.sun.tools.internal.ws.api.TJavaGeneratorExtension;
ohair@286 30 import com.sun.tools.internal.ws.processor.model.*;
ohair@286 31 import com.sun.tools.internal.ws.processor.model.java.JavaInterface;
ohair@286 32 import com.sun.tools.internal.ws.processor.model.java.JavaMethod;
ohair@286 33 import com.sun.tools.internal.ws.processor.model.java.JavaParameter;
ohair@286 34 import com.sun.tools.internal.ws.processor.model.jaxb.JAXBType;
ohair@286 35 import com.sun.tools.internal.ws.processor.model.jaxb.JAXBTypeAndAnnotation;
ohair@286 36 import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
ohair@286 37 import com.sun.tools.internal.ws.wscompile.Options;
ohair@286 38 import com.sun.tools.internal.ws.wscompile.WsimportOptions;
ohair@286 39 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
ohair@286 40 import com.sun.tools.internal.ws.wsdl.document.PortType;
ohair@286 41 import com.sun.tools.internal.ws.resources.GeneratorMessages;
ohair@286 42
ohair@286 43 import javax.jws.WebMethod;
ohair@286 44 import javax.jws.WebParam;
ohair@286 45 import javax.jws.WebService;
ohair@286 46 import javax.jws.soap.SOAPBinding;
ohair@286 47 import javax.xml.bind.annotation.XmlSeeAlso;
ohair@286 48 import javax.xml.namespace.QName;
ohair@286 49 import javax.xml.ws.Holder;
ohair@286 50 import java.util.ArrayList;
ohair@286 51 import java.util.List;
ohair@286 52
ohair@286 53 import org.xml.sax.Locator;
ohair@286 54
ohair@286 55 public class SeiGenerator extends GeneratorBase {
ohair@286 56 private TJavaGeneratorExtension extension;
ohair@286 57 private List<TJavaGeneratorExtension> extensionHandlers;
ohair@286 58
ohair@286 59 public static void generate(Model model, WsimportOptions options, ErrorReceiver receiver, TJavaGeneratorExtension... extensions){
ohair@286 60 SeiGenerator seiGenerator = new SeiGenerator();
ohair@286 61 seiGenerator.init(model, options, receiver, extensions);
ohair@286 62 seiGenerator.doGeneration();
ohair@286 63 }
ohair@286 64
ohair@286 65 public void init(Model model, WsimportOptions options, ErrorReceiver receiver, TJavaGeneratorExtension... extensions) {
ohair@286 66 init(model, options, receiver);
ohair@286 67 extensionHandlers = new ArrayList<TJavaGeneratorExtension>();
ohair@286 68
ohair@286 69 // register handlers for default extensions
ohair@286 70
ohair@286 71 // 2.2 Spec requires generation of @Action when wsam:Action is explicitly stated in wsdl
ohair@286 72 if (options.target.isLaterThan(Options.Target.V2_2)) {
ohair@286 73 register(new W3CAddressingJavaGeneratorExtension());
ohair@286 74 }
ohair@286 75
alanb@368 76 for (TJavaGeneratorExtension j : extensions) {
ohair@286 77 register(j);
alanb@368 78 }
ohair@286 79
alanb@368 80 this.extension = new JavaGeneratorExtensionFacade(extensionHandlers.toArray(new TJavaGeneratorExtension[extensionHandlers.size()]));
ohair@286 81 }
ohair@286 82
ohair@286 83 private void write(Port port) {
ohair@286 84 JavaInterface intf = port.getJavaInterface();
ohair@286 85 String className = Names.customJavaTypeClassName(intf);
ohair@286 86
ohair@286 87 if (donotOverride && GeneratorUtil.classExists(options, className)) {
ohair@286 88 log("Class " + className + " exists. Not overriding.");
ohair@286 89 return;
ohair@286 90 }
ohair@286 91
ohair@286 92
alanb@368 93 JDefinedClass cls;
ohair@286 94 try {
ohair@286 95 cls = getClass(className, ClassType.INTERFACE);
ohair@286 96 } catch (JClassAlreadyExistsException e) {
ohair@286 97 QName portTypeName =
ohair@286 98 (QName) port.getProperty(
ohair@286 99 ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME);
ohair@286 100 Locator loc = null;
ohair@286 101 if(portTypeName != null){
ohair@286 102 PortType pt = port.portTypes.get(portTypeName);
alanb@368 103 if (pt!=null) {
ohair@286 104 loc = pt.getLocator();
alanb@368 105 }
ohair@286 106 }
ohair@286 107 receiver.error(loc, GeneratorMessages.GENERATOR_SEI_CLASS_ALREADY_EXIST(intf.getName(), portTypeName));
ohair@286 108 return;
ohair@286 109 }
ohair@286 110 // If the class has methods it has already been defined
ohair@286 111 // so skip it.
alanb@368 112 if (!cls.methods().isEmpty()) {
ohair@286 113 return;
alanb@368 114 }
ohair@286 115
ohair@286 116 //write class comment - JAXWS warning
ohair@286 117 JDocComment comment = cls.javadoc();
ohair@286 118
ohair@286 119 String ptDoc = intf.getJavaDoc();
ohair@286 120 if(ptDoc != null){
ohair@286 121 comment.add(ptDoc);
ohair@286 122 comment.add("\n\n");
ohair@286 123 }
ohair@286 124
ohair@286 125 for(String doc:getJAXWSClassComment()){
ohair@286 126 comment.add(doc);
ohair@286 127 }
ohair@286 128
ohair@286 129
ohair@286 130 //@WebService
ohair@286 131 JAnnotationUse webServiceAnn = cls.annotate(cm.ref(WebService.class));
ohair@286 132 writeWebServiceAnnotation(port, webServiceAnn);
ohair@286 133
ohair@286 134 //@HandlerChain
ohair@286 135 writeHandlerConfig(Names.customJavaTypeClassName(port.getJavaInterface()), cls, options);
ohair@286 136
ohair@286 137 //@SOAPBinding
ohair@286 138 writeSOAPBinding(port, cls);
ohair@286 139
ohair@286 140 //@XmlSeeAlso
alanb@368 141 if (options.target.isLaterThan(Options.Target.V2_1)) {
ohair@286 142 writeXmlSeeAlso(cls);
alanb@368 143 }
ohair@286 144
ohair@286 145 for (Operation operation: port.getOperations()) {
ohair@286 146 JavaMethod method = operation.getJavaMethod();
ohair@286 147
ohair@286 148 //@WebMethod
ohair@286 149 JMethod m;
ohair@286 150 JDocComment methodDoc;
ohair@286 151 String methodJavaDoc = operation.getJavaDoc();
ohair@286 152 if(method.getReturnType().getName().equals("void")){
ohair@286 153 m = cls.method(JMod.PUBLIC, void.class, method.getName());
ohair@286 154 methodDoc = m.javadoc();
ohair@286 155 }else {
ohair@286 156 JAXBTypeAndAnnotation retType = method.getReturnType().getType();
ohair@286 157 m = cls.method(JMod.PUBLIC, retType.getType(), method.getName());
ohair@286 158 retType.annotate(m);
ohair@286 159 methodDoc = m.javadoc();
ohair@286 160 JCommentPart ret = methodDoc.addReturn();
ohair@286 161 ret.add("returns "+retType.getName());
ohair@286 162 }
alanb@368 163 if (methodJavaDoc != null) {
ohair@286 164 methodDoc.add(methodJavaDoc);
alanb@368 165 }
ohair@286 166
ohair@286 167 writeWebMethod(operation, m);
ohair@286 168 JClass holder = cm.ref(Holder.class);
ohair@286 169 for (JavaParameter parameter: method.getParametersList()) {
ohair@286 170 JVar var;
ohair@286 171 JAXBTypeAndAnnotation paramType = parameter.getType().getType();
ohair@286 172 if (parameter.isHolder()) {
ohair@286 173 var = m.param(holder.narrow(paramType.getType().boxify()), parameter.getName());
ohair@286 174 }else{
ohair@286 175 var = m.param(paramType.getType(), parameter.getName());
ohair@286 176 }
ohair@286 177
ohair@286 178 //annotate parameter with JAXB annotations
ohair@286 179 paramType.annotate(var);
ohair@286 180 methodDoc.addParam(var);
ohair@286 181 JAnnotationUse paramAnn = var.annotate(cm.ref(WebParam.class));
ohair@286 182 writeWebParam(operation, parameter, paramAnn);
ohair@286 183 }
ohair@286 184 com.sun.tools.internal.ws.wsdl.document.Operation wsdlOp = operation.getWSDLPortTypeOperation();
ohair@286 185 for(Fault fault:operation.getFaultsSet()){
ohair@286 186 m._throws(fault.getExceptionClass());
ohair@286 187 methodDoc.addThrows(fault.getExceptionClass());
ohair@286 188 wsdlOp.putFault(fault.getWsdlFaultName(), fault.getExceptionClass());
ohair@286 189 }
ohair@286 190
ohair@286 191 //It should be the last thing to invoke after JMethod is built completely
ohair@286 192 extension.writeMethodAnnotations(wsdlOp, m);
ohair@286 193 }
ohair@286 194 }
ohair@286 195
ohair@286 196 private void writeXmlSeeAlso(JDefinedClass cls) {
ohair@286 197 if (model.getJAXBModel().getS2JJAXBModel() != null) {
ohair@286 198 List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
ohair@286 199
ohair@286 200 //if there are no object facotires, dont generate @XmlSeeAlso
alanb@368 201 if (objectFactories.isEmpty()) {
ohair@286 202 return;
alanb@368 203 }
ohair@286 204
ohair@286 205 JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
ohair@286 206 JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
ohair@286 207 for (JClass of : objectFactories) {
ohair@286 208 paramArray = paramArray.param(of);
ohair@286 209 }
ohair@286 210 }
ohair@286 211
ohair@286 212 }
ohair@286 213
ohair@286 214 private void writeWebMethod(Operation operation, JMethod m) {
ohair@286 215 Response response = operation.getResponse();
ohair@286 216 JAnnotationUse webMethodAnn = m.annotate(cm.ref(WebMethod.class));
ohair@286 217 String operationName = (operation instanceof AsyncOperation)?
ohair@286 218 ((AsyncOperation)operation).getNormalOperation().getName().getLocalPart():
ohair@286 219 operation.getName().getLocalPart();
ohair@286 220
ohair@286 221 if(!m.name().equals(operationName)){
ohair@286 222 webMethodAnn.param("operationName", operationName);
ohair@286 223 }
ohair@286 224
ohair@286 225 if (operation.getSOAPAction() != null && operation.getSOAPAction().length() > 0){
ohair@286 226 webMethodAnn.param("action", operation.getSOAPAction());
ohair@286 227 }
ohair@286 228
ohair@286 229 if (operation.getResponse() == null){
ohair@286 230 m.annotate(javax.jws.Oneway.class);
ohair@286 231 }else if (!operation.getJavaMethod().getReturnType().getName().equals("void") &&
ohair@286 232 operation.getResponse().getParametersList().size() > 0){
ohair@286 233 Block block;
ohair@286 234 String resultName = null;
ohair@286 235 String nsURI = null;
ohair@286 236 if (operation.getResponse().getBodyBlocks().hasNext()) {
ohair@286 237 block = operation.getResponse().getBodyBlocks().next();
ohair@286 238 resultName = block.getName().getLocalPart();
ohair@286 239 if(isDocStyle || block.getLocation() == Block.HEADER){
ohair@286 240 nsURI = block.getName().getNamespaceURI();
ohair@286 241 }
ohair@286 242 }
ohair@286 243
ohair@286 244 for (Parameter parameter : operation.getResponse().getParametersList()) {
ohair@286 245 if (parameter.getParameterIndex() == -1) {
ohair@286 246 if(operation.isWrapped()||!isDocStyle){
ohair@286 247 if(parameter.getBlock().getLocation() == Block.HEADER){
ohair@286 248 resultName = parameter.getBlock().getName().getLocalPart();
ohair@286 249 }else{
ohair@286 250 resultName = parameter.getName();
ohair@286 251 }
ohair@286 252 if (isDocStyle || (parameter.getBlock().getLocation() == Block.HEADER)) {
ohair@286 253 nsURI = parameter.getType().getName().getNamespaceURI();
ohair@286 254 }
ohair@286 255 }else if(isDocStyle){
ohair@286 256 JAXBType t = (JAXBType)parameter.getType();
ohair@286 257 resultName = t.getName().getLocalPart();
ohair@286 258 nsURI = t.getName().getNamespaceURI();
ohair@286 259 }
ohair@286 260 if(!(operation instanceof AsyncOperation)){
ohair@286 261 JAnnotationUse wr = null;
ohair@286 262
ohair@286 263 if(!resultName.equals("return")){
ohair@286 264 wr = m.annotate(javax.jws.WebResult.class);
ohair@286 265 wr.param("name", resultName);
ohair@286 266 }
alanb@368 267 if (nsURI != null || (isDocStyle && operation.isWrapped())) {
alanb@368 268 if(wr == null) {
ohair@286 269 wr = m.annotate(javax.jws.WebResult.class);
alanb@368 270 }
ohair@286 271 wr.param("targetNamespace", nsURI);
ohair@286 272 }
ohair@286 273 //doclit wrapped could have additional headers
ohair@286 274 if(!(isDocStyle && operation.isWrapped()) ||
ohair@286 275 (parameter.getBlock().getLocation() == Block.HEADER)){
alanb@368 276 if (wr == null) {
ohair@286 277 wr = m.annotate(javax.jws.WebResult.class);
alanb@368 278 }
ohair@286 279 wr.param("partName", parameter.getName());
ohair@286 280 }
ohair@286 281 if(parameter.getBlock().getLocation() == Block.HEADER){
alanb@368 282 if (wr == null) {
ohair@286 283 wr = m.annotate(javax.jws.WebResult.class);
alanb@368 284 }
ohair@286 285 wr.param("header",true);
ohair@286 286 }
ohair@286 287 }
ohair@286 288 }
ohair@286 289
ohair@286 290 }
ohair@286 291 }
ohair@286 292
ohair@286 293 //DOC/BARE
ohair@286 294 if (!sameParamStyle) {
ohair@286 295 if(!operation.isWrapped()) {
ohair@286 296 JAnnotationUse sb = m.annotate(SOAPBinding.class);
ohair@286 297 sb.param("parameterStyle", SOAPBinding.ParameterStyle.BARE);
ohair@286 298 }
ohair@286 299 }
ohair@286 300
ohair@286 301 if (operation.isWrapped() && operation.getStyle().equals(SOAPStyle.DOCUMENT)) {
ohair@286 302 Block reqBlock = operation.getRequest().getBodyBlocks().next();
ohair@286 303 JAnnotationUse reqW = m.annotate(javax.xml.ws.RequestWrapper.class);
ohair@286 304 reqW.param("localName", reqBlock.getName().getLocalPart());
ohair@286 305 reqW.param("targetNamespace", reqBlock.getName().getNamespaceURI());
ohair@286 306 reqW.param("className", reqBlock.getType().getJavaType().getName());
ohair@286 307
ohair@286 308 if (response != null) {
ohair@286 309 JAnnotationUse resW = m.annotate(javax.xml.ws.ResponseWrapper.class);
ohair@286 310 Block resBlock = response.getBodyBlocks().next();
ohair@286 311 resW.param("localName", resBlock.getName().getLocalPart());
ohair@286 312 resW.param("targetNamespace", resBlock.getName().getNamespaceURI());
ohair@286 313 resW.param("className", resBlock.getType().getJavaType().getName());
ohair@286 314 }
ohair@286 315 }
ohair@286 316 }
ohair@286 317
ohair@286 318 private boolean isMessageParam(Parameter param, Message message) {
ohair@286 319 Block block = param.getBlock();
ohair@286 320
ohair@286 321 return (message.getBodyBlockCount() > 0 && block.equals(message.getBodyBlocks().next())) ||
ohair@286 322 (message.getHeaderBlockCount() > 0 &&
ohair@286 323 block.equals(message.getHeaderBlocks().next()));
ohair@286 324 }
ohair@286 325
ohair@286 326 private boolean isHeaderParam(Parameter param, Message message) {
alanb@368 327 if (message.getHeaderBlockCount() == 0) {
ohair@286 328 return false;
alanb@368 329 }
ohair@286 330
alanb@368 331 for (Block headerBlock : message.getHeaderBlocksMap().values()) {
alanb@368 332 if (param.getBlock().equals(headerBlock)) {
ohair@286 333 return true;
alanb@368 334 }
alanb@368 335 }
ohair@286 336
ohair@286 337 return false;
ohair@286 338 }
ohair@286 339
ohair@286 340 private boolean isAttachmentParam(Parameter param, Message message){
alanb@368 341 if (message.getAttachmentBlockCount() == 0) {
ohair@286 342 return false;
alanb@368 343 }
ohair@286 344
alanb@368 345 for (Block attBlock : message.getAttachmentBlocksMap().values()) {
alanb@368 346 if (param.getBlock().equals(attBlock)) {
ohair@286 347 return true;
alanb@368 348 }
alanb@368 349 }
ohair@286 350
ohair@286 351 return false;
ohair@286 352 }
ohair@286 353
ohair@286 354 private boolean isUnboundParam(Parameter param, Message message){
alanb@368 355 if (message.getUnboundBlocksCount() == 0) {
ohair@286 356 return false;
alanb@368 357 }
ohair@286 358
alanb@368 359 for (Block unboundBlock : message.getUnboundBlocksMap().values()) {
alanb@368 360 if (param.getBlock().equals(unboundBlock)) {
ohair@286 361 return true;
alanb@368 362 }
alanb@368 363 }
ohair@286 364
ohair@286 365 return false;
ohair@286 366 }
ohair@286 367
ohair@286 368 private void writeWebParam(Operation operation, JavaParameter javaParameter, JAnnotationUse paramAnno) {
ohair@286 369 Parameter param = javaParameter.getParameter();
ohair@286 370 Request req = operation.getRequest();
ohair@286 371 Response res = operation.getResponse();
ohair@286 372
ohair@286 373 boolean header = isHeaderParam(param, req) ||
ohair@286 374 (res != null && isHeaderParam(param, res));
ohair@286 375
ohair@286 376 String name;
ohair@286 377 boolean isWrapped = operation.isWrapped();
ohair@286 378
alanb@368 379 if ((param.getBlock().getLocation() == Block.HEADER) || (isDocStyle && !isWrapped)) {
ohair@286 380 name = param.getBlock().getName().getLocalPart();
alanb@368 381 } else {
ohair@286 382 name = param.getName();
alanb@368 383 }
ohair@286 384
ohair@286 385 paramAnno.param("name", name);
ohair@286 386
ohair@286 387 String ns= null;
ohair@286 388
ohair@286 389 if (isDocStyle) {
ohair@286 390 ns = param.getBlock().getName().getNamespaceURI(); // its bare nsuri
ohair@286 391 if(isWrapped){
ohair@286 392 ns = param.getType().getName().getNamespaceURI();
ohair@286 393 }
ohair@286 394 }else if(header){
ohair@286 395 ns = param.getBlock().getName().getNamespaceURI();
ohair@286 396 }
ohair@286 397
alanb@368 398 if (ns != null || (isDocStyle && isWrapped)) {
ohair@286 399 paramAnno.param("targetNamespace", ns);
alanb@368 400 }
ohair@286 401
ohair@286 402 if (header) {
ohair@286 403 paramAnno.param("header", true);
ohair@286 404 }
ohair@286 405
ohair@286 406 if (param.isINOUT()){
ohair@286 407 paramAnno.param("mode", javax.jws.WebParam.Mode.INOUT);
ohair@286 408 }else if ((res != null) && (isMessageParam(param, res) || isHeaderParam(param, res) || isAttachmentParam(param, res) ||
ohair@286 409 isUnboundParam(param,res) || param.isOUT())){
ohair@286 410 paramAnno.param("mode", javax.jws.WebParam.Mode.OUT);
ohair@286 411 }
ohair@286 412
ohair@286 413 //doclit wrapped could have additional headers
alanb@368 414 if (!(isDocStyle && isWrapped) || header) {
ohair@286 415 paramAnno.param("partName", javaParameter.getParameter().getName());
alanb@368 416 }
ohair@286 417 }
ohair@286 418
ohair@286 419 private boolean isDocStyle = true;
ohair@286 420 private boolean sameParamStyle = true;
ohair@286 421 private void writeSOAPBinding(Port port, JDefinedClass cls) {
ohair@286 422 JAnnotationUse soapBindingAnn = null;
ohair@286 423 isDocStyle = port.getStyle() == null || port.getStyle().equals(SOAPStyle.DOCUMENT);
ohair@286 424 if(!isDocStyle){
ohair@286 425 soapBindingAnn = cls.annotate(SOAPBinding.class);
ohair@286 426 soapBindingAnn.param("style", SOAPBinding.Style.RPC);
ohair@286 427 port.setWrapped(true);
ohair@286 428 }
ohair@286 429 if(isDocStyle){
ohair@286 430 boolean first = true;
ohair@286 431 boolean isWrapper = true;
ohair@286 432 for(Operation operation:port.getOperations()){
ohair@286 433 if(first){
ohair@286 434 isWrapper = operation.isWrapped();
ohair@286 435 first = false;
ohair@286 436 continue;
ohair@286 437 }
ohair@286 438 sameParamStyle = (isWrapper == operation.isWrapped());
alanb@368 439 if (!sameParamStyle) {
ohair@286 440 break;
alanb@368 441 }
ohair@286 442 }
alanb@368 443 if (sameParamStyle) {
ohair@286 444 port.setWrapped(isWrapper);
alanb@368 445 }
ohair@286 446 }
ohair@286 447 if(sameParamStyle && !port.isWrapped()){
alanb@368 448 if (soapBindingAnn == null) {
ohair@286 449 soapBindingAnn = cls.annotate(SOAPBinding.class);
alanb@368 450 }
ohair@286 451 soapBindingAnn.param("parameterStyle", SOAPBinding.ParameterStyle.BARE);
ohair@286 452 }
ohair@286 453 }
ohair@286 454
ohair@286 455 private void writeWebServiceAnnotation(Port port, JAnnotationUse wsa) {
ohair@286 456 QName name = (QName) port.getProperty(ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME);
ohair@286 457 wsa.param("name", name.getLocalPart());
ohair@286 458 wsa.param("targetNamespace", name.getNamespaceURI());
ohair@286 459 }
ohair@286 460
alanb@368 461 @Override
ohair@286 462 public void visit(Model model) throws Exception {
ohair@286 463 for(Service s:model.getServices()){
ohair@286 464 s.accept(this);
ohair@286 465 }
ohair@286 466 }
ohair@286 467
alanb@368 468 @Override
ohair@286 469 public void visit(Service service) throws Exception {
ohair@286 470 String jd = model.getJavaDoc();
ohair@286 471 if(jd != null){
ohair@286 472 JPackage pkg = cm._package(options.defaultPackage);
ohair@286 473 pkg.javadoc().add(jd);
ohair@286 474 }
ohair@286 475
ohair@286 476 for(Port p:service.getPorts()){
ohair@286 477 visitPort(service, p);
ohair@286 478 }
ohair@286 479 }
ohair@286 480
ohair@286 481 private void visitPort(Service service, Port port) {
ohair@286 482 if (port.isProvider()) {
ohair@286 483 return; // Not generating for Provider based endpoint
ohair@286 484 }
ohair@286 485 write(port);
ohair@286 486 }
ohair@286 487
ohair@286 488 private void register(TJavaGeneratorExtension h) {
ohair@286 489 extensionHandlers.add(h);
ohair@286 490 }
ohair@286 491 }

mercurial