/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import com.sun.tools.internal.ws.processor.modeler.annotation.AnnotationProcessorContext.SEIContext;
/**
*
* @author WS Development Team
*/
public abstract class WebServiceVisitor extends SimpleDeclarationVisitor implements WebServiceConstants {
protected boolean wrapped = true;
protected boolean processingSEI = false;
protected boolean endpointReferencesInterface = false;
protected boolean hasWebMethods = false;
protected boolean pushedSOAPBinding = false;
protected static final String ANNOTATION_ELEMENT_ERROR = "webserviceap.endpointinteface.plus.element";
this.simpleTypeCreator = new JavaSimpleTypeCreator();
}
if (!shouldProcessWebService(webService, d))
return;
if (builder.checkAndSetProcessed(d))
return;
typeDecl = d;
builder.onError(d.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_ENDPOINTINTERFACES_DO_NOT_MATCH(endpointInterfaceName, d.getQualifiedName()));
}
processingSEI = true;
}
if (!shouldProcessWebService(webService, d))
return;
if (builder.checkAndSetProcessed(d))
return;
typeDecl = d;
if (serviceImplName == null)
serviceImplName = d.getQualifiedName();
checkForInvalidImplAnnotation(d, SOAPBinding.class);
annotationError(pos, WebserviceapMessages.localizableWEBSERVICEAP_ENDPOINTINTEFACE_PLUS_ELEMENT("name"));
endpointReferencesInterface = true;
return;
}
processingSEI = false;
}
builder.onError(d.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_ENDPOINTINTERFACE_ON_INTERFACE(d.getQualifiedName(), webService.endpointInterface()));
}
builder.onError(d.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT("serviceName", d.getQualifiedName()));
}
builder.onError(d.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT("portName", d.getQualifiedName()));
}
}
}
}
}
if (annotation != null) {
annotationError(pos, WebserviceapMessages.localizableWEBSERVICEAP_INVALID_SEI_ANNOTATION(annotationClass.getName(), d.getQualifiedName()));
}
}
if (annotation != null) {
annotationError(pos, WebserviceapMessages.localizableWEBSERVICEAP_ENDPOINTINTEFACE_PLUS_ANNOTATION(annotationClass.getName()));
}
}
}
if (webService != null)
builder.onError(d.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(d.getQualifiedName()));
}
}
if (serviceImplName == null)
if (serviceImplName != null) {
}
d.getSimpleName().replace(
SIGC_UNDERSCORE));;
if (soapBinding != null) {
}
}
return true;
return true;
return false;
}
boolean changed = false;
changed = true;
if (pushedSOAPBinding)
builder.onError(bindingDecl.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_MIXED_BINDING_STYLE(classDecl.getQualifiedName()));
}
wrapped = true;
builder.onError(bindingDecl.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_RPC_LITERAL_MUST_NOT_BE_BARE(classDecl.getQualifiedName()));
}
} else {
changed = true;
}
}
style = "document";
builder.onError(bindingDecl.getPosition(), WebserviceapMessages.localizableWEBSERVICE_ENCODED_NOT_SUPPORTED(classDecl.getQualifiedName(), style));
}
pushedSOAPBinding = true;
}
return changed;
}
if (pushedSOAPBinding)
if (!soapBindingStack.empty()) {
wrapped = true;
} else {
}
}
return soapBinding;
}
}
// abstract protected boolean shouldProcessWebService(WebService webService, InterfaceDeclaration intf);
// abstract protected boolean shouldProcessWebService(WebService webService, ClassDeclaration decl);
hasWebMethods = false;
if (webService == null)
builder.onError(intf.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_ENDPOINTINTERFACE_HAS_NO_WEBSERVICE_ANNOTATION(intf.getQualifiedName()));
if(soapBinding != null && soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
builder.onError(intf.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_INVALID_SOAPBINDING_PARAMETERSTYLE(soapBinding, intf));
return false;
}
if (isLegalSEI(intf))
return true;
return false;
}
if (webService == null)
return false;
if(soapBinding != null && soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
builder.onError(classDecl.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_INVALID_SOAPBINDING_PARAMETERSTYLE(soapBinding, classDecl));
return false;
}
}
processMethods(d);
}
processMethods(d);
}
return false;
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_INVALID_WEBMETHOD_ELEMENT_WITH_EXCLUDE("operationName", d.getQualifiedName(), method.toString()));
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_INVALID_WEBMETHOD_ELEMENT_WITH_EXCLUDE("action", d.getQualifiedName(), method.toString()));
} else {
return true;
}
}
}
return false;//hasWebMethods(d.getSuperclass().getDeclaration());
}
hasWebMethods = false;
methodDecl.accept(this);
}
}
hasWebMethods = hasWebMethods(d);
return;
// Super classes must have @WebService annotations to pick up their methods
methodDecl.accept(this);
}
}
if (d.getSuperclass() != null) {
}
}
ClassDeclaration d) {
assert(seiContext != null);
seiContext.setImplementsSEI(true);
break;
}
}
if (intTypeDecl == null) {
}
if (intTypeDecl == null)
builder.onError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTERFACE_CLASS_NOT_FOUND(endpointInterfaceName));
return intTypeDecl;
}
if (intTypeDecl != null)
intTypeDecl.accept(this);
}
// Methods must be public
return;
if (processedMethod(method))
return;
return;
if (soapBinding != null)
else {
soapBinding = new MySOAPBinding();
}
}
}
boolean newBinding = false;
if (soapBinding != null) {
}
try {
}
} finally {
if (newBinding) {
}
}
}
return true;
return false;
}
builder.log("should process method: "+method.getSimpleName()+" hasWebMethods: "+ hasWebMethods+" ");
/*
if (hasWebMethods && webMethod == null) {
builder.log("webMethod == null");
return false;
}
*/
if (staticFinal) {
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getDeclaringType(), method));
}
return false;
}
boolean retval = (endpointReferencesInterface ||
builder.log("declaring class has WebSevice: "+(method.getDeclaringType().getAnnotation(WebService.class) != null));
return retval;
}
builder.onError(classDecl.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_WEBSERVICE_CLASS_NOT_PUBLIC(classDecl.getQualifiedName()));
return false;
}
builder.onError(classDecl.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_WEBSERVICE_CLASS_IS_FINAL(classDecl.getQualifiedName()));
return false;
}
builder.onError(classDecl.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_WEBSERVICE_CLASS_IS_ABSTRACT(classDecl.getQualifiedName()));
return false;
}
boolean hasDefaultConstructor = false;
hasDefaultConstructor = true;
break;
}
}
if (!hasDefaultConstructor && !isStateful) {
builder.onError(classDecl.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_WEBSERVICE_CLASS_IS_INNERCLASS_NOT_STATIC(classDecl.getQualifiedName()));
return false;
}
builder.onError(classDecl.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_WEBSERVICE_NO_DEFAULT_CONSTRUCTOR(classDecl.getQualifiedName()));
return false;
}
if (!methodsAreLegal(classDecl))
return false;
} else {
InterfaceDeclaration intfDecl = getEndpointInterfaceDecl(webService.endpointInterface(), classDecl);
return false;
}
return true;
}
try {
// We don't want dependency on rt-ha module as its not integrated in JDK
return classDecl.getAnnotation((Class <? extends Annotation>)Class.forName("com.sun.xml.internal.ws.developer.Stateful"))!=null;
} catch (ClassNotFoundException e) {
//ignore
}
return false;
}
return true;
}
boolean implementsMethod;
implementsMethod = false;
implementsMethod = true;
break;
}
}
if (!implementsMethod) {
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_METHOD_NOT_IMPLEMENTED(intfDecl.getSimpleName(), classDecl.getSimpleName(), method));
return false;
}
}
return true;
}
return false;
return false;
return false;
int pos = 0;
return false;
}
return true;
}
builder.onError(WebserviceapMessages.WEBSERVICEAP_SEI_CANNOT_CONTAIN_CONSTANT_VALUES(intf.getQualifiedName(), field.getSimpleName()));
return false;
}
if (!methodsAreLegal(intf))
return false;
return true;
}
hasWebMethods = false;
return false;
}
return false;
}
return true;
}
return false;
}
if (!superClass.getDeclaration().getQualifiedName().equals(JAVA_LANG_OBJECT) && !methodsAreLegal(superClass.getDeclaration())) {
return false;
}
return true;
}
//SEI cannot have methods with @WebMethod(exclude=true)
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeDecl.getQualifiedName(), method.toString()));
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
// if (hasWebMethods && (webMethod == null))
// return true;
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeDecl instanceof ClassDeclaration && method.getModifiers().contains(Modifier.ABSTRACT)) {
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeDecl.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeDecl.getQualifiedName(),
method.getReturnType()));
}
return false;
if (soapBinding != null) {
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeDecl.getQualifiedName(), method.toString()));
}
}
int paramIndex = 0;
return false;
}
if (!isDocLitWrapped() &&
if (inParams != 1) {
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeDecl.getQualifiedName(), method.toString()));
}
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_DOC_BARE_NO_OUT(typeDecl.getQualifiedName(), method.toString()));
}
if (outParams != 1) {
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeDecl.getQualifiedName(), method.toString()));
}
} else {
if (outParams > 0) {
builder.onError(outParam.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeDecl.getQualifiedName(), method.toString()));
}
}
}
return true;
}
int paramIndex) {
builder.onError(param.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_METHOD_PARAMETER_TYPES_CANNOT_IMPLEMENT_REMOTE(typeDecl.getQualifiedName(),
return false;
}
if (holderType != null) {
builder.onError(param.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_HOLDER_PARAMETERS_MUST_NOT_BE_IN_ONLY(typeDecl.getQualifiedName(), method.toString(), paramIndex));
builder.onError(param.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_NON_IN_PARAMETERS_MUST_BE_HOLDER(typeDecl.getQualifiedName(), method.toString(), paramIndex));
}
return true;
}
protected boolean isDocLitWrapped() {
}
boolean valid = true;
// this is an error, cannot be Oneway and have a return type
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_ONEWAY_OPERATION_CANNOT_HAVE_RETURN_TYPE(typeDecl.getQualifiedName(), method.toString()));
valid = false;
}
builder.onError(outParam.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_ONEWAY_AND_OUT(typeDecl.getQualifiedName(), method.toString()));
valid = false;
}
if (inCnt != 1) {
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_ONEWAY_AND_NOT_ONE_IN(typeDecl.getQualifiedName(), method.toString()));
valid = false;
}
}
builder.onError(method.getPosition(), WebserviceapMessages.localizableWEBSERVICEAP_ONEWAY_OPERATION_CANNOT_DECLARE_EXCEPTIONS(typeDecl.getQualifiedName(), method.toString(), exDecl.getQualifiedName()));
valid = false;
}
}
return valid;
}
int cnt = 0;
continue;
cnt++;
} else {
cnt++;
}
}
}
return cnt;
}
return true;
return true;
return true;
return false;
}
}
if (!(type instanceof DeclaredType))
return true;
// can be null, if this type's declaration is unknown. This may be the result of a processing error, such as a missing class file.
builder.onError(WebserviceapMessages.WEBSERVICEAP_COULD_NOT_FIND_TYPEDECL(type.toString(), context.getRound()));
}
}
return param;
}
}
return null;
}
return SOAPBinding.class;
}
}
}