use of org.apache.cxf.tools.common.model.JAnnotation in project cxf by apache.
the class XmlJavaTypeAdapterAnnotator method annotate.
public void annotate(JavaAnnotatable jn) {
JAnnotation jaxbAnnotation = new JAnnotation(XmlJavaTypeAdapter.class);
jaxbAnnotation.addElement(new JAnnotationElement("value", adapter));
if (jn instanceof JavaParameter) {
JavaParameter jp = (JavaParameter) jn;
jp.addAnnotation("XmlJavaTypeAdapter", jaxbAnnotation);
} else if (jn instanceof JavaMethod) {
JavaMethod jm = (JavaMethod) jn;
jm.addAnnotation("XmlJavaTypeAdapter", jaxbAnnotation);
} else {
throw new RuntimeException("Annotation of " + jn.getClass() + " not supported.");
}
jf.addImport(XmlJavaTypeAdapter.class.getName());
jf.addImport(adapter.getName());
}
use of org.apache.cxf.tools.common.model.JAnnotation in project cxf by apache.
the class WebMethodAnnotator method annotate.
public void annotate(JavaAnnotatable ja) {
final JavaMethod method;
if (ja instanceof JavaMethod) {
method = (JavaMethod) ja;
} else {
throw new RuntimeException("WebMethod can only annotate JavaMethod");
}
String operationName = method.getOperationName();
JAnnotation methodAnnotation = new JAnnotation(WebMethod.class);
if (!method.getName().equals(operationName)) {
methodAnnotation.addElement(new JAnnotationElement("operationName", operationName));
}
if (!StringUtils.isEmpty(method.getSoapAction())) {
methodAnnotation.addElement(new JAnnotationElement("action", method.getSoapAction()));
}
method.addAnnotation("WebMethod", methodAnnotation);
}
use of org.apache.cxf.tools.common.model.JAnnotation in project cxf by apache.
the class WrapperAnnotator method annotate.
public void annotate(JavaAnnotatable ja) {
JavaMethod method;
if (ja instanceof JavaMethod) {
method = (JavaMethod) ja;
} else {
throw new RuntimeException("RequestWrapper and ResponseWrapper can only annotate JavaMethod");
}
if (wrapperRequest != null) {
JAnnotation requestAnnotation = new JAnnotation(RequestWrapper.class);
requestAnnotation.addElement(new JAnnotationElement("localName", wrapperRequest.getType()));
requestAnnotation.addElement(new JAnnotationElement("targetNamespace", wrapperRequest.getTargetNamespace()));
requestAnnotation.addElement(new JAnnotationElement("className", wrapperRequest.getClassName()));
method.addAnnotation("RequestWrapper", requestAnnotation);
method.getInterface().addImports(requestAnnotation.getImports());
}
if (wrapperResponse != null) {
List<JAnnotationElement> elements = new ArrayList<>();
elements.add(new JAnnotationElement("localName", wrapperResponse.getType()));
elements.add(new JAnnotationElement("targetNamespace", wrapperResponse.getTargetNamespace()));
elements.add(new JAnnotationElement("className", wrapperResponse.getClassName()));
JAnnotation responseAnnotation = new JAnnotation(ResponseWrapper.class);
responseAnnotation.getElements().addAll(elements);
method.addAnnotation("ResponseWrapper", responseAnnotation);
method.getInterface().addImports(responseAnnotation.getImports());
}
}
use of org.apache.cxf.tools.common.model.JAnnotation in project cxf by apache.
the class XmlListAnotator method annotate.
public void annotate(JavaAnnotatable jn) {
JAnnotation jaxbAnnotation = new JAnnotation(XmlList.class);
if (jn instanceof JavaParameter) {
JavaParameter jp = (JavaParameter) jn;
jp.addAnnotation("XmlList", jaxbAnnotation);
} else if (jn instanceof JavaMethod) {
JavaMethod jm = (JavaMethod) jn;
jm.addAnnotation("XmlList", jaxbAnnotation);
} else {
throw new RuntimeException("XmlList can only annotate to JavaParameter or JavaMethod");
}
jf.addImport(XmlList.class.getName());
}
use of org.apache.cxf.tools.common.model.JAnnotation in project cxf by apache.
the class OperationProcessor method addPollingMethod.
private void addPollingMethod(JavaMethod method) throws ToolException {
JavaMethod pollingMethod = new JavaMethod(method.getInterface());
pollingMethod.setAsync(true);
pollingMethod.setName(method.getName() + ToolConstants.ASYNC_METHOD_SUFFIX);
pollingMethod.setStyle(method.getStyle());
pollingMethod.setWrapperStyle(method.isWrapperStyle());
pollingMethod.setSoapAction(method.getSoapAction());
pollingMethod.setOperationName(method.getOperationName());
boolean convertOutToAsync = !method.isWrapperStyle() && "void".equals(method.getReturn().getClassName());
String asyncCname = null;
for (JavaParameter param : method.getParameters()) {
if (convertOutToAsync) {
if (param.isHolder()) {
if (param.isINOUT()) {
JavaParameter p2 = new JavaParameter();
p2.setName(param.getName());
p2.setClassName(param.getHolderName());
p2.setStyle(JavaType.Style.IN);
pollingMethod.addParameter(p2);
for (String s : param.getAnnotationTags()) {
JAnnotation ann = param.getAnnotation(s);
p2.addAnnotation(s, ann);
}
} else if (!param.isHeader() && asyncCname == null) {
asyncCname = param.getClassName();
}
} else {
pollingMethod.addParameter(param);
}
} else {
pollingMethod.addParameter(param);
}
}
JavaReturn response = new JavaReturn();
response.setClassName(getAsyncClassName(method, "Response", asyncCname));
pollingMethod.setReturn(response);
// REVISIT: test the operation name in the annotation
pollingMethod.annotate(new WebMethodAnnotator());
pollingMethod.addAnnotation("RequestWrapper", method.getAnnotationMap().get("RequestWrapper"));
pollingMethod.addAnnotation("ResponseWrapper", method.getAnnotationMap().get("ResponseWrapper"));
pollingMethod.addAnnotation("SOAPBinding", method.getAnnotationMap().get("SOAPBinding"));
method.getInterface().addMethod(pollingMethod);
}
Aggregations