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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations