src/share/jaxws_classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceVisitor.java

Print this page
rev 472 : 8036030: Update JAX-WS RI integration to latest version
   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.internal.ws.processor.modeler.annotation;
  27 
  28 import com.sun.tools.internal.ws.processor.model.Port;
  29 import com.sun.tools.internal.ws.resources.WebserviceapMessages;
  30 import com.sun.tools.internal.ws.util.ClassNameInfo;
  31 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
  32 import com.sun.xml.internal.ws.model.RuntimeModeler;
  33 
  34 import javax.annotation.processing.ProcessingEnvironment;
  35 import javax.jws.Oneway;
  36 import javax.jws.WebMethod;
  37 import javax.jws.WebParam;
  38 import javax.jws.WebResult;
  39 import javax.jws.WebService;
  40 import javax.jws.soap.SOAPBinding;
  41 import javax.jws.soap.SOAPBinding.ParameterStyle;
  42 import javax.lang.model.element.Element;
  43 import javax.lang.model.element.ElementKind;
  44 import javax.lang.model.element.ExecutableElement;
  45 import javax.lang.model.element.Modifier;
  46 import javax.lang.model.element.Name;
  47 import javax.lang.model.element.PackageElement;
  48 import javax.lang.model.element.TypeElement;
  49 import javax.lang.model.element.VariableElement;
  50 import javax.lang.model.type.DeclaredType;
  51 import javax.lang.model.type.NoType;
  52 import javax.lang.model.type.TypeKind;
  53 import javax.lang.model.type.TypeMirror;
  54 import javax.lang.model.util.ElementFilter;


 592 
 593     protected boolean sameMethod(ExecutableElement method1, ExecutableElement method2) {
 594         if (!method1.getSimpleName().equals(method2.getSimpleName()))
 595             return false;
 596         Types typeUtils = builder.getProcessingEnvironment().getTypeUtils();
 597         if(!typeUtils.isSameType(method1.getReturnType(), method2.getReturnType())
 598                 && !typeUtils.isSubtype(method2.getReturnType(), method1.getReturnType()))
 599             return false;
 600         List<? extends VariableElement> parameters1 = method1.getParameters();
 601         List<? extends VariableElement> parameters2 = method2.getParameters();
 602         if (parameters1.size() != parameters2.size())
 603             return false;
 604         for (int i = 0; i < parameters1.size(); i++) {
 605             if (!typeUtils.isSameType(parameters1.get(i).asType(), parameters2.get(i).asType()))
 606                 return false;
 607         }
 608         return true;
 609     }
 610 
 611     protected boolean isLegalSei(TypeElement interfaceElement) {
 612         for (VariableElement field : ElementFilter.fieldsIn(interfaceElement.getEnclosedElements()))
 613             if (field.getConstantValue() != null) {
 614                 builder.processError(WebserviceapMessages.WEBSERVICEAP_SEI_CANNOT_CONTAIN_CONSTANT_VALUES(
 615                         interfaceElement.getQualifiedName(), field.getSimpleName()));
 616                 return false;
 617             }
 618         return methodsAreLegal(interfaceElement);
 619     }
 620 
 621     protected boolean methodsAreLegal(TypeElement element) {
 622         switch (element.getKind()) {
 623             case INTERFACE: {
 624                 hasWebMethods = false;
 625                 for (ExecutableElement method : ElementFilter.methodsIn(element.getEnclosedElements())) {
 626                     if (!isLegalMethod(method, element))
 627                         return false;
 628                 }
 629                 for (TypeMirror superInterface : element.getInterfaces()) {
 630                     if (!methodsAreLegal((TypeElement) ((DeclaredType) superInterface).asElement()))
 631                         return false;
 632                 }
 633                 return true;
 634             }
 635             case CLASS: {
 636                 hasWebMethods = hasWebMethods(element);
 637                 for (ExecutableElement method : ElementFilter.methodsIn(element.getEnclosedElements())) {


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.internal.ws.processor.modeler.annotation;
  27 
  28 import com.sun.tools.internal.ws.processor.model.Port;
  29 import com.sun.tools.internal.ws.resources.WebserviceapMessages;
  30 import com.sun.tools.internal.ws.util.ClassNameInfo;
  31 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
  32 import com.sun.xml.internal.ws.model.RuntimeModeler;
  33 

  34 import javax.jws.Oneway;
  35 import javax.jws.WebMethod;
  36 import javax.jws.WebParam;
  37 import javax.jws.WebResult;
  38 import javax.jws.WebService;
  39 import javax.jws.soap.SOAPBinding;
  40 import javax.jws.soap.SOAPBinding.ParameterStyle;
  41 import javax.lang.model.element.Element;
  42 import javax.lang.model.element.ElementKind;
  43 import javax.lang.model.element.ExecutableElement;
  44 import javax.lang.model.element.Modifier;
  45 import javax.lang.model.element.Name;
  46 import javax.lang.model.element.PackageElement;
  47 import javax.lang.model.element.TypeElement;
  48 import javax.lang.model.element.VariableElement;
  49 import javax.lang.model.type.DeclaredType;
  50 import javax.lang.model.type.NoType;
  51 import javax.lang.model.type.TypeKind;
  52 import javax.lang.model.type.TypeMirror;
  53 import javax.lang.model.util.ElementFilter;


 591 
 592     protected boolean sameMethod(ExecutableElement method1, ExecutableElement method2) {
 593         if (!method1.getSimpleName().equals(method2.getSimpleName()))
 594             return false;
 595         Types typeUtils = builder.getProcessingEnvironment().getTypeUtils();
 596         if(!typeUtils.isSameType(method1.getReturnType(), method2.getReturnType())
 597                 && !typeUtils.isSubtype(method2.getReturnType(), method1.getReturnType()))
 598             return false;
 599         List<? extends VariableElement> parameters1 = method1.getParameters();
 600         List<? extends VariableElement> parameters2 = method2.getParameters();
 601         if (parameters1.size() != parameters2.size())
 602             return false;
 603         for (int i = 0; i < parameters1.size(); i++) {
 604             if (!typeUtils.isSameType(parameters1.get(i).asType(), parameters2.get(i).asType()))
 605                 return false;
 606         }
 607         return true;
 608     }
 609 
 610     protected boolean isLegalSei(TypeElement interfaceElement) {






 611         return methodsAreLegal(interfaceElement);
 612     }
 613 
 614     protected boolean methodsAreLegal(TypeElement element) {
 615         switch (element.getKind()) {
 616             case INTERFACE: {
 617                 hasWebMethods = false;
 618                 for (ExecutableElement method : ElementFilter.methodsIn(element.getEnclosedElements())) {
 619                     if (!isLegalMethod(method, element))
 620                         return false;
 621                 }
 622                 for (TypeMirror superInterface : element.getInterfaces()) {
 623                     if (!methodsAreLegal((TypeElement) ((DeclaredType) superInterface).asElement()))
 624                         return false;
 625                 }
 626                 return true;
 627             }
 628             case CLASS: {
 629                 hasWebMethods = hasWebMethods(element);
 630                 for (ExecutableElement method : ElementFilter.methodsIn(element.getEnclosedElements())) {