@Override protected TypeMirror getHolderValueType(TypeMirror paramType) { return builder.getHolderValueType(paramType); }
private void addGeneratedFile(String requestClassName) { File file = new File(DirectoryUtil.getOutputDirectoryFor(requestClassName, builder.getSourceDir()), Names.stripQualifier(requestClassName) + GeneratorConstants.JAVA_SRC_SUFFIX.getValue()); builder.getOptions().addGeneratedFile(file); }
private TypeElement getEndpointInterfaceElement(String endpointInterfaceName, TypeElement element) { TypeElement intTypeElement = null; for (TypeMirror interfaceType : element.getInterfaces()) { if (endpointInterfaceName.equals(interfaceType.toString())) { intTypeElement = (TypeElement) ((DeclaredType) interfaceType).asElement(); seiContext = context.getSeiContext(intTypeElement.getQualifiedName()); assert (seiContext != null); seiContext.setImplementsSei(true); break; } } if (intTypeElement == null) { intTypeElement = builder.getProcessingEnvironment().getElementUtils().getTypeElement(endpointInterfaceName); } if (intTypeElement == null) builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTERFACE_CLASS_NOT_FOUND(endpointInterfaceName)); return intTypeElement; }
protected boolean isLegalType(TypeMirror type) { if (!(type != null && type.getKind().equals(TypeKind.DECLARED))) return true; TypeElement tE = (TypeElement) ((DeclaredType) type).asElement(); if (tE == null) { // 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.processError(WebserviceapMessages.WEBSERVICEAP_COULD_NOT_FIND_TYPEDECL(type.toString(), context.getRound())); } return !builder.isRemote(tE); }
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) { builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " "); /* Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577 if (hasWebMethods && webMethod == null) { builder.log("webMethod == null"); return false; } */ Collection<Modifier> modifiers = method.getModifiers(); boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL); if (staticFinal) { if (webMethod != null) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(), method), method); } return false; } boolean result = (endpointReferencesInterface || method.getEnclosingElement().equals(typeElement) || (method.getEnclosingElement().getAnnotation(WebService.class) != null)); builder.log("endpointReferencesInterface: " + endpointReferencesInterface); builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null)); builder.log("returning: " + result); return result; }
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false;
beanPackage = JAXWS_PACKAGE_PD.getValue(); Name methodName = method.getSimpleName(); String operationName = builder.getOperationName(methodName); operationName = webMethod != null && webMethod.operationName().length() > 0 ? webMethod.operationName() : operationName; reqNamespace = reqWrapper.targetNamespace(); builder.log("requestWrapper: "+requestClassName); boolean canOverwriteRequest = builder.canOverWriteClass(requestClassName); if (!canOverwriteRequest) { builder.log("Class " + requestClassName + " exists. Not overwriting."); builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_REQUEST_WRAPPER_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), method.toString())); resNamespace = resWrapper.targetNamespace(); canOverwriteResponse = builder.canOverWriteClass(responseClassName); if (!canOverwriteResponse) { builder.log("Class " + responseClassName + " exists. Not overwriting."); builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RESPONSE_WRAPPER_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), method.toString()));
protected boolean isLegalParameter(VariableElement param, ExecutableElement method, TypeElement typeElement, int paramIndex) { if (!isLegalType(param.asType())) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_PARAMETER_TYPES_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(), method.getSimpleName(), param.getSimpleName(), param.asType().toString()), param); return false; } TypeMirror holderType; holderType = builder.getHolderValueType(param.asType()); WebParam webParam = param.getAnnotation(WebParam.class); WebParam.Mode mode = null; if (webParam != null) mode = webParam.mode(); if (holderType != null) { if (mode != null && mode == WebParam.Mode.IN) builder.processError(WebserviceapMessages.WEBSERVICEAP_HOLDER_PARAMETERS_MUST_NOT_BE_IN_ONLY(typeElement.getQualifiedName(), method.toString(), paramIndex), param); } else if (mode != null && mode != WebParam.Mode.IN) { builder.processError(WebserviceapMessages.WEBSERVICEAP_NON_IN_PARAMETERS_MUST_BE_HOLDER(typeElement.getQualifiedName(), method.toString(), paramIndex), param); } return true; }
protected boolean isValidOneWayMethod(ExecutableElement method, TypeElement typeElement) { boolean valid = true; if (!(method.getReturnType().accept(NO_TYPE_VISITOR, null))) { // this is an error, cannot be OneWay and have a return type builder.processError(WebserviceapMessages.WEBSERVICEAP_ONEWAY_OPERATION_CANNOT_HAVE_RETURN_TYPE(typeElement.getQualifiedName(), method.toString()), method); valid = false; } VariableElement outParam = getOutParameter(method); if (outParam != null) { builder.processError(WebserviceapMessages.WEBSERVICEAP_ONEWAY_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam); valid = false; } if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) { int inCnt = getModeParameterCount(method, WebParam.Mode.IN); if (inCnt != 1) { builder.processError(WebserviceapMessages.WEBSERVICEAP_ONEWAY_AND_NOT_ONE_IN(typeElement.getQualifiedName(), method.toString()), method); valid = false; } } for (TypeMirror thrownType : method.getThrownTypes()) { TypeElement thrownElement = (TypeElement) ((DeclaredType) thrownType).asElement(); if (builder.isServiceException(thrownType)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_ONEWAY_OPERATION_CANNOT_DECLARE_EXCEPTIONS( typeElement.getQualifiedName(), method.toString(), thrownElement.getQualifiedName()), method); valid = false; } } return valid; }
if (!shouldProcessWebService(webService, e)) return null; if (builder.checkAndSetProcessed(e)) return null; typeElement = e; case INTERFACE: { if (endpointInterfaceName != null && !endpointInterfaceName.equals(e.getQualifiedName())) { builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTERFACES_DO_NOT_MATCH(endpointInterfaceName, e.getQualifiedName()), e); checkForInvalidImplAnnotation(e, SOAPBinding.class); if (webService.name().length() > 0) builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTEFACE_PLUS_ELEMENT("name"), e); endpointReferencesInterface = true; verifyImplAnnotations(e);
@Override protected void processMethod(ExecutableElement method, WebMethod webMethod) { builder.log("WrapperGen - method: "+method); builder.log("method.getDeclaringType(): " + method.asType()); if (wrapped && soapStyle.equals(SOAPStyle.DOCUMENT)) { generateWrappers(method, webMethod); } generateExceptionBeans(method); }
public WebServiceWrapperGenerator(ModelBuilder builder, AnnotationProcessorContext context) { super(builder, context); makeSafeVisitor = new MakeSafeTypeVisitor(builder.getProcessingEnvironment()); }
@SuppressWarnings("CallToThreadDumpStack") protected void doPostProcessWebService(WebService webService, TypeElement d) { if (cm != null) { WsgenOptions options = builder.getOptions(); assert options.filer != null; try { CodeWriter cw = new FilerCodeWriter(options); if(options.verbose) cw = new ProgressCodeWriter(cw, System.out); cm.build(cw); } catch (IOException e) { e.printStackTrace(); } } }
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false;
beanPackage = JAXWS_PACKAGE_PD.getValue(); Name methodName = method.getSimpleName(); String operationName = builder.getOperationName(methodName); operationName = webMethod != null && webMethod.operationName().length() > 0 ? webMethod.operationName() : operationName; reqNamespace = reqWrapper.targetNamespace(); builder.log("requestWrapper: "+requestClassName); boolean canOverwriteRequest = builder.canOverWriteClass(requestClassName); if (!canOverwriteRequest) { builder.log("Class " + requestClassName + " exists. Not overwriting."); builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_REQUEST_WRAPPER_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), method.toString())); resNamespace = resWrapper.targetNamespace(); canOverwriteResponse = builder.canOverWriteClass(responseClassName); if (!canOverwriteResponse) { builder.log("Class " + responseClassName + " exists. Not overwriting."); builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RESPONSE_WRAPPER_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), method.toString()));
protected boolean isLegalType(TypeMirror type) { if (!(type != null && type.getKind().equals(TypeKind.DECLARED))) return true; TypeElement tE = (TypeElement) ((DeclaredType) type).asElement(); if (tE == null) { // 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.processError(WebserviceapMessages.WEBSERVICEAP_COULD_NOT_FIND_TYPEDECL(type.toString(), context.getRound())); } return !builder.isRemote(tE); }
protected boolean isLegalParameter(VariableElement param, ExecutableElement method, TypeElement typeElement, int paramIndex) { if (!isLegalType(param.asType())) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_PARAMETER_TYPES_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(), method.getSimpleName(), param.getSimpleName(), param.asType().toString()), param); return false; } TypeMirror holderType; holderType = builder.getHolderValueType(param.asType()); WebParam webParam = param.getAnnotation(WebParam.class); WebParam.Mode mode = null; if (webParam != null) mode = webParam.mode(); if (holderType != null) { if (mode != null && mode == WebParam.Mode.IN) builder.processError(WebserviceapMessages.WEBSERVICEAP_HOLDER_PARAMETERS_MUST_NOT_BE_IN_ONLY(typeElement.getQualifiedName(), method.toString(), paramIndex), param); } else if (mode != null && mode != WebParam.Mode.IN) { builder.processError(WebserviceapMessages.WEBSERVICEAP_NON_IN_PARAMETERS_MUST_BE_HOLDER(typeElement.getQualifiedName(), method.toString(), paramIndex), param); } return true; }
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) { builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " "); /* Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577 if (hasWebMethods && webMethod == null) { builder.log("webMethod == null"); return false; } */ Collection<Modifier> modifiers = method.getModifiers(); boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL); if (staticFinal) { if (webMethod != null) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(), method), method); } return false; } boolean result = (endpointReferencesInterface || method.getEnclosingElement().equals(typeElement) || (method.getEnclosingElement().getAnnotation(WebService.class) != null)); builder.log("endpointReferencesInterface: " + endpointReferencesInterface); builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null)); builder.log("returning: " + result); return result; }
protected boolean isValidOneWayMethod(ExecutableElement method, TypeElement typeElement) { boolean valid = true; if (!(method.getReturnType().accept(NO_TYPE_VISITOR, null))) { // this is an error, cannot be OneWay and have a return type builder.processError(WebserviceapMessages.WEBSERVICEAP_ONEWAY_OPERATION_CANNOT_HAVE_RETURN_TYPE(typeElement.getQualifiedName(), method.toString()), method); valid = false; } VariableElement outParam = getOutParameter(method); if (outParam != null) { builder.processError(WebserviceapMessages.WEBSERVICEAP_ONEWAY_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam); valid = false; } if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) { int inCnt = getModeParameterCount(method, WebParam.Mode.IN); if (inCnt != 1) { builder.processError(WebserviceapMessages.WEBSERVICEAP_ONEWAY_AND_NOT_ONE_IN(typeElement.getQualifiedName(), method.toString()), method); valid = false; } } for (TypeMirror thrownType : method.getThrownTypes()) { TypeElement thrownElement = (TypeElement) ((DeclaredType) thrownType).asElement(); if (builder.isServiceException(thrownType)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_ONEWAY_OPERATION_CANNOT_DECLARE_EXCEPTIONS( typeElement.getQualifiedName(), method.toString(), thrownElement.getQualifiedName()), method); valid = false; } } return valid; }
if (!shouldProcessWebService(webService, e)) return null; if (builder.checkAndSetProcessed(e)) return null; typeElement = e; case INTERFACE: { if (endpointInterfaceName != null && !endpointInterfaceName.equals(e.getQualifiedName())) { builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTERFACES_DO_NOT_MATCH(endpointInterfaceName, e.getQualifiedName()), e); checkForInvalidImplAnnotation(e, SOAPBinding.class); if (webService.name().length() > 0) builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTEFACE_PLUS_ELEMENT("name"), e); endpointReferencesInterface = true; verifyImplAnnotations(e);