Search in sources :

Example 1 with JavaType

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);
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) JavaType(org.apache.cxf.tools.common.model.JavaType) JAnnotation(org.apache.cxf.tools.common.model.JAnnotation) JAnnotationElement(org.apache.cxf.tools.common.model.JAnnotationElement) ArrayList(java.util.ArrayList)

Example 2 with JavaType

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);
            }
        }
    }
}
Also used : JavaType(org.apache.cxf.tools.common.model.JavaType) MIMEContent(javax.wsdl.extensions.mime.MIMEContent) Message(org.apache.cxf.common.i18n.Message) JavaParameter(org.apache.cxf.tools.common.model.JavaParameter) ToolException(org.apache.cxf.tools.common.ToolException) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) SOAPHeader(javax.wsdl.extensions.soap.SOAPHeader) MIMEPart(javax.wsdl.extensions.mime.MIMEPart)

Aggregations

JavaType (org.apache.cxf.tools.common.model.JavaType)2 ArrayList (java.util.ArrayList)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 MIMEContent (javax.wsdl.extensions.mime.MIMEContent)1 MIMEPart (javax.wsdl.extensions.mime.MIMEPart)1 SOAPHeader (javax.wsdl.extensions.soap.SOAPHeader)1 Message (org.apache.cxf.common.i18n.Message)1 ToolException (org.apache.cxf.tools.common.ToolException)1 JAnnotation (org.apache.cxf.tools.common.model.JAnnotation)1 JAnnotationElement (org.apache.cxf.tools.common.model.JAnnotationElement)1 JavaInterface (org.apache.cxf.tools.common.model.JavaInterface)1 JavaParameter (org.apache.cxf.tools.common.model.JavaParameter)1