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

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
     1.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/generator/SeiGenerator.java	Thu Apr 04 19:05:24 2013 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/generator/SeiGenerator.java	Tue Apr 09 14:51:13 2013 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -36,10 +36,8 @@
    1.11  import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
    1.12  import com.sun.tools.internal.ws.wscompile.Options;
    1.13  import com.sun.tools.internal.ws.wscompile.WsimportOptions;
    1.14 -import com.sun.tools.internal.ws.wscompile.AbortException;
    1.15  import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
    1.16  import com.sun.tools.internal.ws.wsdl.document.PortType;
    1.17 -import com.sun.tools.internal.ws.wsdl.document.Kinds;
    1.18  import com.sun.tools.internal.ws.resources.GeneratorMessages;
    1.19  
    1.20  import javax.jws.WebMethod;
    1.21 @@ -55,7 +53,6 @@
    1.22  import org.xml.sax.Locator;
    1.23  
    1.24  public class SeiGenerator extends GeneratorBase {
    1.25 -    private String serviceNS;
    1.26      private TJavaGeneratorExtension extension;
    1.27      private List<TJavaGeneratorExtension> extensionHandlers;
    1.28  
    1.29 @@ -76,10 +73,11 @@
    1.30             register(new W3CAddressingJavaGeneratorExtension());
    1.31          }
    1.32  
    1.33 -        for (TJavaGeneratorExtension j : extensions)
    1.34 +        for (TJavaGeneratorExtension j : extensions) {
    1.35              register(j);
    1.36 +        }
    1.37  
    1.38 -        this.extension = new JavaGeneratorExtensionFacade(extensionHandlers.toArray(new TJavaGeneratorExtension[0]));
    1.39 +        this.extension = new JavaGeneratorExtensionFacade(extensionHandlers.toArray(new TJavaGeneratorExtension[extensionHandlers.size()]));
    1.40      }
    1.41  
    1.42      private void write(Port port) {
    1.43 @@ -92,7 +90,7 @@
    1.44          }
    1.45  
    1.46  
    1.47 -        JDefinedClass cls = null;
    1.48 +        JDefinedClass cls;
    1.49          try {
    1.50              cls = getClass(className, ClassType.INTERFACE);
    1.51          } catch (JClassAlreadyExistsException e) {
    1.52 @@ -102,16 +100,18 @@
    1.53              Locator loc = null;
    1.54              if(portTypeName != null){
    1.55                  PortType pt = port.portTypes.get(portTypeName);
    1.56 -                if(pt!=null)
    1.57 +                if (pt!=null) {
    1.58                      loc = pt.getLocator();
    1.59 +                }
    1.60              }
    1.61              receiver.error(loc, GeneratorMessages.GENERATOR_SEI_CLASS_ALREADY_EXIST(intf.getName(), portTypeName));
    1.62              return;
    1.63          }
    1.64          // If the class has methods it has already been defined
    1.65          // so skip it.
    1.66 -        if (!cls.methods().isEmpty())
    1.67 +        if (!cls.methods().isEmpty()) {
    1.68              return;
    1.69 +        }
    1.70  
    1.71          //write class comment - JAXWS warning
    1.72          JDocComment comment = cls.javadoc();
    1.73 @@ -138,8 +138,9 @@
    1.74          writeSOAPBinding(port, cls);
    1.75  
    1.76          //@XmlSeeAlso
    1.77 -        if(options.target.isLaterThan(Options.Target.V2_1))
    1.78 +        if (options.target.isLaterThan(Options.Target.V2_1)) {
    1.79              writeXmlSeeAlso(cls);
    1.80 +        }
    1.81  
    1.82          for (Operation operation: port.getOperations()) {
    1.83              JavaMethod method = operation.getJavaMethod();
    1.84 @@ -159,8 +160,9 @@
    1.85                  JCommentPart ret = methodDoc.addReturn();
    1.86                  ret.add("returns "+retType.getName());
    1.87              }
    1.88 -            if(methodJavaDoc != null)
    1.89 +            if (methodJavaDoc != null) {
    1.90                  methodDoc.add(methodJavaDoc);
    1.91 +            }
    1.92  
    1.93              writeWebMethod(operation, m);
    1.94              JClass holder = cm.ref(Holder.class);
    1.95 @@ -196,8 +198,9 @@
    1.96              List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
    1.97  
    1.98              //if there are no object facotires, dont generate @XmlSeeAlso
    1.99 -            if(objectFactories.size() == 0)
   1.100 +            if (objectFactories.isEmpty()) {
   1.101                  return;
   1.102 +            }
   1.103  
   1.104              JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
   1.105              JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
   1.106 @@ -261,21 +264,24 @@
   1.107                              wr = m.annotate(javax.jws.WebResult.class);
   1.108                              wr.param("name", resultName);
   1.109                          }
   1.110 -                        if((nsURI != null) && (!nsURI.equals(serviceNS) || (isDocStyle && operation.isWrapped()))){
   1.111 -                            if(wr == null)
   1.112 +                        if (nsURI != null || (isDocStyle && operation.isWrapped())) {
   1.113 +                            if(wr == null) {
   1.114                                  wr = m.annotate(javax.jws.WebResult.class);
   1.115 +                            }
   1.116                              wr.param("targetNamespace", nsURI);
   1.117                          }
   1.118                          //doclit wrapped could have additional headers
   1.119                          if(!(isDocStyle && operation.isWrapped()) ||
   1.120                                  (parameter.getBlock().getLocation() == Block.HEADER)){
   1.121 -                            if(wr == null)
   1.122 +                            if (wr == null) {
   1.123                                  wr = m.annotate(javax.jws.WebResult.class);
   1.124 +                            }
   1.125                              wr.param("partName", parameter.getName());
   1.126                          }
   1.127                          if(parameter.getBlock().getLocation() == Block.HEADER){
   1.128 -                            if(wr == null)
   1.129 +                            if (wr == null) {
   1.130                                  wr = m.annotate(javax.jws.WebResult.class);
   1.131 +                            }
   1.132                              wr.param("header",true);
   1.133                          }
   1.134                      }
   1.135 @@ -318,34 +324,43 @@
   1.136      }
   1.137  
   1.138      private boolean isHeaderParam(Parameter param, Message message) {
   1.139 -        if (message.getHeaderBlockCount() == 0)
   1.140 +        if (message.getHeaderBlockCount() == 0) {
   1.141              return false;
   1.142 +        }
   1.143  
   1.144 -        for (Block headerBlock : message.getHeaderBlocksMap().values())
   1.145 -            if (param.getBlock().equals(headerBlock))
   1.146 +        for (Block headerBlock : message.getHeaderBlocksMap().values()) {
   1.147 +            if (param.getBlock().equals(headerBlock)) {
   1.148                  return true;
   1.149 +            }
   1.150 +        }
   1.151  
   1.152          return false;
   1.153      }
   1.154  
   1.155      private boolean isAttachmentParam(Parameter param, Message message){
   1.156 -        if (message.getAttachmentBlockCount() == 0)
   1.157 +        if (message.getAttachmentBlockCount() == 0) {
   1.158              return false;
   1.159 +        }
   1.160  
   1.161 -        for (Block attBlock : message.getAttachmentBlocksMap().values())
   1.162 -            if (param.getBlock().equals(attBlock))
   1.163 +        for (Block attBlock : message.getAttachmentBlocksMap().values()) {
   1.164 +            if (param.getBlock().equals(attBlock)) {
   1.165                  return true;
   1.166 +            }
   1.167 +        }
   1.168  
   1.169          return false;
   1.170      }
   1.171  
   1.172      private boolean isUnboundParam(Parameter param, Message message){
   1.173 -        if (message.getUnboundBlocksCount() == 0)
   1.174 +        if (message.getUnboundBlocksCount() == 0) {
   1.175              return false;
   1.176 +        }
   1.177  
   1.178 -        for (Block unboundBlock : message.getUnboundBlocksMap().values())
   1.179 -            if (param.getBlock().equals(unboundBlock))
   1.180 +        for (Block unboundBlock : message.getUnboundBlocksMap().values()) {
   1.181 +            if (param.getBlock().equals(unboundBlock)) {
   1.182                  return true;
   1.183 +            }
   1.184 +        }
   1.185  
   1.186          return false;
   1.187      }
   1.188 @@ -361,10 +376,11 @@
   1.189          String name;
   1.190          boolean isWrapped = operation.isWrapped();
   1.191  
   1.192 -        if((param.getBlock().getLocation() == Block.HEADER) || (isDocStyle && !isWrapped))
   1.193 +        if ((param.getBlock().getLocation() == Block.HEADER) || (isDocStyle && !isWrapped)) {
   1.194              name = param.getBlock().getName().getLocalPart();
   1.195 -        else
   1.196 +        } else {
   1.197              name = param.getName();
   1.198 +        }
   1.199  
   1.200          paramAnno.param("name", name);
   1.201  
   1.202 @@ -379,8 +395,9 @@
   1.203              ns = param.getBlock().getName().getNamespaceURI();
   1.204          }
   1.205  
   1.206 -        if((ns != null) && (!ns.equals(serviceNS) || (isDocStyle && isWrapped)))
   1.207 +        if (ns != null || (isDocStyle && isWrapped)) {
   1.208              paramAnno.param("targetNamespace", ns);
   1.209 +        }
   1.210  
   1.211          if (header) {
   1.212              paramAnno.param("header", true);
   1.213 @@ -394,8 +411,9 @@
   1.214          }
   1.215  
   1.216          //doclit wrapped could have additional headers
   1.217 -        if(!(isDocStyle && isWrapped) || header)
   1.218 +        if (!(isDocStyle && isWrapped) || header) {
   1.219              paramAnno.param("partName", javaParameter.getParameter().getName());
   1.220 +        }
   1.221      }
   1.222  
   1.223      private boolean isDocStyle = true;
   1.224 @@ -418,15 +436,18 @@
   1.225                      continue;
   1.226                  }
   1.227                  sameParamStyle = (isWrapper == operation.isWrapped());
   1.228 -                if(!sameParamStyle)
   1.229 +                if (!sameParamStyle) {
   1.230                      break;
   1.231 +                }
   1.232              }
   1.233 -            if(sameParamStyle)
   1.234 +            if (sameParamStyle) {
   1.235                  port.setWrapped(isWrapper);
   1.236 +            }
   1.237          }
   1.238          if(sameParamStyle && !port.isWrapped()){
   1.239 -            if(soapBindingAnn == null)
   1.240 +            if (soapBindingAnn == null) {
   1.241                  soapBindingAnn = cls.annotate(SOAPBinding.class);
   1.242 +            }
   1.243              soapBindingAnn.param("parameterStyle", SOAPBinding.ParameterStyle.BARE);
   1.244          }
   1.245      }
   1.246 @@ -437,15 +458,14 @@
   1.247          wsa.param("targetNamespace", name.getNamespaceURI());
   1.248      }
   1.249  
   1.250 -
   1.251 -
   1.252 -
   1.253 +    @Override
   1.254      public void visit(Model model) throws Exception {
   1.255          for(Service s:model.getServices()){
   1.256              s.accept(this);
   1.257          }
   1.258      }
   1.259  
   1.260 +    @Override
   1.261      public void visit(Service service) throws Exception {
   1.262          String jd = model.getJavaDoc();
   1.263          if(jd != null){

mercurial