use of org.apache.cxf.tools.common.model.JavaType in project cxf by apache.
the class XmlSeeAlsoAnnotator method annotate.
public void annotate(JavaAnnotatable ja) {
if (collector == null || collector.getTypesPackages().isEmpty()) {
return;
}
final JavaInterface intf;
if (ja instanceof JavaInterface) {
intf = (JavaInterface) ja;
} else {
throw new RuntimeException("XmlSeeAlso can only annotate JavaInterface");
}
JAnnotation jaxbAnnotation = new JAnnotation(XmlSeeAlso.class);
intf.addImports(jaxbAnnotation.getImports());
List<JavaType> types = new ArrayList<>();
for (String pkg : collector.getTypesPackages()) {
if (pkg.equals(intf.getPackageName())) {
types.add(new JavaType(null, "ObjectFactory", null));
} else {
types.add(new JavaType(null, pkg + ".ObjectFactory", null));
}
}
jaxbAnnotation.addElement(new JAnnotationElement(null, types));
intf.addAnnotation(jaxbAnnotation);
}
use of org.apache.cxf.tools.common.model.JavaType in project cxf by apache.
the class ServiceProcessor method processMultipart.
public void processMultipart(JavaMethod jm, BindingOperationInfo operation, MIMEMultipartRelated ext, JavaType.Style style) throws ToolException {
List<MIMEPart> mimeParts = CastUtils.cast(ext.getMIMEParts());
for (MIMEPart mPart : mimeParts) {
List<ExtensibilityElement> extns = CastUtils.cast(mPart.getExtensibilityElements());
for (ExtensibilityElement extElement : extns) {
if (extElement instanceof MIMEContent) {
MIMEContent mimeContent = (MIMEContent) extElement;
String mimeJavaType = getJavaTypeForMimeType(mPart);
if (JavaType.Style.IN.equals(style)) {
String paramName = ProcessorUtil.mangleNameToVariableName(mimeContent.getPart());
JavaParameter jp = jm.getParameter(paramName);
if (jp == null) {
Message message = new Message("MIMEPART_CANNOT_MAP", LOG, mimeContent.getPart());
throw new ToolException(message);
}
if (!jp.getClassName().equals(mimeJavaType)) {
// jp.setType(mimeJavaType);
jp.setClassName(mimeJavaType);
}
} else if (JavaType.Style.OUT.equals(style)) {
JavaType jp = null;
if (!"void".equals(jm.getReturn().getType()) && mimeContent.getPart().equals(jm.getReturn().getName())) {
jp = jm.getReturn();
jp.setClassName(mimeJavaType);
}
if (jp == null) {
for (JavaParameter para : jm.getParameters()) {
if (mimeContent.getPart().equals(para.getPartName())) {
jp = para;
}
}
if (jp != null) {
((JavaParameter) jp).setClassName(mimeJavaType);
}
}
if (jp == null) {
Message message = new Message("MIMEPART_CANNOT_MAP", LOG, mimeContent.getPart());
throw new ToolException(message);
}
}
} else if (extElement instanceof SOAPHeader) {
processSoapHeader(jm, operation, extElement);
}
}
}
}
Aggregations