Search in sources :

Example 1 with WebParam

use of jakarta.jws.WebParam in project metro-jax-ws by eclipse-ee4j.

the class WebServiceVisitor method isLegalParameter.

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 == 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;
}
Also used : WebParam(jakarta.jws.WebParam) TypeMirror(javax.lang.model.type.TypeMirror)

Example 2 with WebParam

use of jakarta.jws.WebParam in project metro-jax-ws by eclipse-ee4j.

the class AbstractWrapperBeanGenerator method collectRequestBeanMembers.

/**
 * Computes request bean members for a method. Collects all IN and INOUT
 * parameters as request bean fields. In this process, if a parameter
 * has any known JAXB annotations they are collected as well.
 * Special processing for @XmlElement annotation is done.
 *
 * @param method SEI method for which request bean members are computed
 * @return List of request bean members
 */
public List<A> collectRequestBeanMembers(M method) {
    List<A> requestMembers = new ArrayList<>();
    int paramIndex = -1;
    for (T param : nav.getMethodParameters(method)) {
        paramIndex++;
        WebParam webParam = annReader.getMethodParameterAnnotation(WebParam.class, method, paramIndex, null);
        if (webParam != null && (webParam.header() || webParam.mode().equals(WebParam.Mode.OUT))) {
            continue;
        }
        T holderType = getHolderValueType(param);
        // if (holderType != null && webParam != null && webParam.mode().equals(WebParam.Mode.IN)) {
        // // Should we flag an error - holder cannot be IN part ??
        // continue;
        // }
        T paramType = (holderType != null) ? holderType : getSafeType(param);
        String paramName = (webParam != null && webParam.name().length() > 0) ? webParam.name() : "arg" + paramIndex;
        String paramNamespace = (webParam != null && webParam.targetNamespace().length() > 0) ? webParam.targetNamespace() : EMTPY_NAMESPACE_ID;
        // Collect JAXB annotations on a parameter
        List<Annotation> jaxbAnnotation = collectJAXBAnnotations(method, paramIndex);
        // If a parameter contains @XmlElement, process it.
        processXmlElement(jaxbAnnotation, paramName, paramNamespace, paramType);
        A member = factory.createWrapperBeanMember(paramType, getPropertyName(paramName), jaxbAnnotation);
        requestMembers.add(member);
    }
    return requestMembers;
}
Also used : WebParam(jakarta.jws.WebParam) Annotation(java.lang.annotation.Annotation)

Example 3 with WebParam

use of jakarta.jws.WebParam in project metro-jax-ws by eclipse-ee4j.

the class AbstractWrapperBeanGenerator method collectResponseBeanMembers.

/**
 * Computes response bean members for a method. Collects all OUT and INOUT
 * parameters as response bean fields. In this process, if a parameter
 * has any known JAXB annotations they are collected as well.
 * Special processing for @XmlElement annotation is done.
 *
 * @param method SEI method for which response bean members are computed
 * @return List of response bean members
 */
public List<A> collectResponseBeanMembers(M method) {
    List<A> responseMembers = new ArrayList<>();
    // return that need to be part response wrapper bean
    String responseElementName = RETURN;
    String responseNamespace = EMTPY_NAMESPACE_ID;
    boolean isResultHeader = false;
    WebResult webResult = annReader.getMethodAnnotation(WebResult.class, method, null);
    if (webResult != null) {
        if (webResult.name().length() > 0) {
            responseElementName = webResult.name();
        }
        if (webResult.targetNamespace().length() > 0) {
            responseNamespace = webResult.targetNamespace();
        }
        isResultHeader = webResult.header();
    }
    T returnType = getSafeType(nav.getReturnType(method));
    if (!isVoidType(returnType) && !isResultHeader) {
        List<Annotation> jaxbRespAnnotations = collectJAXBAnnotations(method);
        processXmlElement(jaxbRespAnnotations, responseElementName, responseNamespace, returnType);
        responseMembers.add(factory.createWrapperBeanMember(returnType, getPropertyName(responseElementName), jaxbRespAnnotations));
    }
    // Now parameters that need to be part response wrapper bean
    int paramIndex = -1;
    for (T param : nav.getMethodParameters(method)) {
        paramIndex++;
        T paramType = getHolderValueType(param);
        WebParam webParam = annReader.getMethodParameterAnnotation(WebParam.class, method, paramIndex, null);
        if (paramType == null || (webParam != null && webParam.header())) {
            // not a holder or a header - so don't add it
            continue;
        }
        String paramName = (webParam != null && webParam.name().length() > 0) ? webParam.name() : "arg" + paramIndex;
        String paramNamespace = (webParam != null && webParam.targetNamespace().length() > 0) ? webParam.targetNamespace() : EMTPY_NAMESPACE_ID;
        List<Annotation> jaxbAnnotation = collectJAXBAnnotations(method, paramIndex);
        processXmlElement(jaxbAnnotation, paramName, paramNamespace, paramType);
        A member = factory.createWrapperBeanMember(paramType, getPropertyName(paramName), jaxbAnnotation);
        responseMembers.add(member);
    }
    return responseMembers;
}
Also used : WebParam(jakarta.jws.WebParam) WebResult(jakarta.jws.WebResult) Annotation(java.lang.annotation.Annotation)

Example 4 with WebParam

use of jakarta.jws.WebParam in project metro-jax-ws by eclipse-ee4j.

the class JWSAnnotationReader method getAnnotations.

public Annotation[] getAnnotations(Method m) {
    Annotation[] anno = m.getAnnotations();
    int webResultPos = -1;
    for (int i = 0; i < anno.length; i++) if (anno[i] instanceof WebParam) {
        webResultPos = i;
    }
    WebResult webResult = getAnnotation(WebResult.class, m);
    if (webResultPos == -1) {
        anno = append(anno, webResult);
    } else {
        anno[webResultPos] = webResult;
    }
    return anno;
}
Also used : WebParam(jakarta.jws.WebParam) WebResult(jakarta.jws.WebResult) Annotation(java.lang.annotation.Annotation)

Example 5 with WebParam

use of jakarta.jws.WebParam in project metro-jax-ws by eclipse-ee4j.

the class WebServiceVisitor method getModeParameterCount.

protected int getModeParameterCount(ExecutableElement method, WebParam.Mode mode) {
    WebParam webParam;
    int cnt = 0;
    for (VariableElement param : method.getParameters()) {
        webParam = param.getAnnotation(WebParam.class);
        if (webParam != null) {
            if (webParam.header())
                continue;
            if (isEquivalentModes(mode, webParam.mode()))
                cnt++;
        } else {
            if (isEquivalentModes(mode, WebParam.Mode.IN)) {
                cnt++;
            }
        }
    }
    return cnt;
}
Also used : WebParam(jakarta.jws.WebParam) VariableElement(javax.lang.model.element.VariableElement)

Aggregations

WebParam (jakarta.jws.WebParam)5 Annotation (java.lang.annotation.Annotation)3 WebResult (jakarta.jws.WebResult)2 VariableElement (javax.lang.model.element.VariableElement)1 TypeMirror (javax.lang.model.type.TypeMirror)1