Search in sources :

Example 1 with DataBindingProfile

use of org.apache.cxf.tools.wsdlto.core.DataBindingProfile in project cxf by apache.

the class WSDLToJavaContainer method generateTypes.

public void generateTypes() throws ToolException {
    DataBindingProfile dataBindingProfile = context.get(DataBindingProfile.class);
    if (dataBindingProfile == null) {
        Message msg = new Message("FOUND_NO_DATABINDING", LOG);
        throw new ToolException(msg);
    }
    dataBindingProfile.initialize(context);
    if (passthrough()) {
        return;
    }
    dataBindingProfile.generate(context);
}
Also used : Message(org.apache.cxf.common.i18n.Message) DataBindingProfile(org.apache.cxf.tools.wsdlto.core.DataBindingProfile) ToolException(org.apache.cxf.tools.common.ToolException)

Example 2 with DataBindingProfile

use of org.apache.cxf.tools.wsdlto.core.DataBindingProfile in project cxf by apache.

the class WSDLToJava method run.

public void run(ToolContext context, OutputStream os) throws Exception {
    if (os != null) {
        this.out = (os instanceof PrintStream) ? (PrintStream) os : new PrintStream(os);
    }
    final FrontEndProfile frontend;
    if (args != null) {
        context.put(ToolConstants.CFG_CMD_ARG, args);
        frontend = loadFrontEnd(getFrontEndName(args));
    } else {
        frontend = loadFrontEnd("");
    }
    context.put(FrontEndProfile.class, frontend);
    DataBindingProfile databinding = loadDataBinding(getDataBindingName(args));
    context.put(DataBindingProfile.class, databinding);
    Class<? extends ToolContainer> containerClass = frontend.getContainerClass();
    InputStream toolspecStream = getResourceAsStream(containerClass, frontend.getToolspec());
    ToolRunner.runTool(containerClass, toolspecStream, false, args, isExitOnFinish(), context, os);
}
Also used : PrintStream(java.io.PrintStream) InputStream(java.io.InputStream) DataBindingProfile(org.apache.cxf.tools.wsdlto.core.DataBindingProfile) FrontEndProfile(org.apache.cxf.tools.wsdlto.core.FrontEndProfile)

Example 3 with DataBindingProfile

use of org.apache.cxf.tools.wsdlto.core.DataBindingProfile in project cxf by apache.

the class ProcessorUtil method resolvePartType.

public static String resolvePartType(MessagePartInfo part, ToolContext context, boolean fullName) {
    DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
    if (dataBinding == null) {
        String primitiveType = JAXBUtils.builtInTypeToJavaType(part.getTypeQName().getLocalPart());
        if (part.getTypeQName() != null && primitiveType != null) {
            return primitiveType;
        }
        return resolvePartType(part);
    }
    String name;
    if (part.isElement()) {
        name = dataBinding.getType(getElementName(part), true);
    } else {
        name = dataBinding.getType(part.getTypeQName(), false);
    }
    if (name == null) {
        String namespace = resolvePartNamespace(part);
        if ("http://www.w3.org/2005/08/addressing".equals(namespace)) {
            // The ws-addressing stuff isn't mapped in jaxb as jax-ws specifies they
            // need to be mapped differently
            String pn = part.getConcreteName().getLocalPart();
            if ("EndpointReference".equals(pn) || "ReplyTo".equals(pn) || "From".equals(pn) || "FaultTo".equals(pn)) {
                name = "javax.xml.ws.wsaddressing.W3CEndpointReference";
            }
        }
    }
    return name;
}
Also used : DataBindingProfile(org.apache.cxf.tools.wsdlto.core.DataBindingProfile)

Example 4 with DataBindingProfile

use of org.apache.cxf.tools.wsdlto.core.DataBindingProfile in project cxf by apache.

the class ProcessorUtil method getType.

public static String getType(MessagePartInfo part, ToolContext context, boolean fullname) {
    String type;
    DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
    if (part.isElement()) {
        type = dataBinding.getType(getElementName(part), true);
    } else {
        type = dataBinding.getType(part.getTypeQName(), false);
    }
    if (type == null) {
        type = resolvePartType(part);
    }
    return type;
}
Also used : DataBindingProfile(org.apache.cxf.tools.wsdlto.core.DataBindingProfile)

Example 5 with DataBindingProfile

use of org.apache.cxf.tools.wsdlto.core.DataBindingProfile in project cxf by apache.

the class ProcessorUtil method getFullClzName.

// 
// the non-wrapper style will get the type info from the part directly
// 
public static String getFullClzName(MessagePartInfo part, ToolContext context, boolean primitiveType) {
    DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
    String jtype = null;
    QName xmlTypeName = getElementName(part);
    if (!primitiveType && dataBinding != null) {
        jtype = dataBinding.getType(xmlTypeName, true);
    }
    if (!primitiveType && dataBinding == null) {
        Class<?> holderClass = JAXBUtils.holderClass(xmlTypeName.getLocalPart());
        jtype = holderClass == null ? null : holderClass.getName();
        if (jtype == null) {
            jtype = JAXBUtils.builtInTypeToJavaType(xmlTypeName.getLocalPart());
        }
    }
    if (primitiveType) {
        jtype = JAXBUtils.builtInTypeToJavaType(xmlTypeName.getLocalPart());
    }
    String namespace = xmlTypeName.getNamespaceURI();
    String type = resolvePartType(part, context, true);
    String userPackage = context.mapPackageName(namespace);
    ClassCollector collector = context.get(ClassCollector.class);
    if (jtype == null) {
        jtype = collector.getTypesFullClassName(parsePackageName(namespace, userPackage), type);
    }
    if (jtype == null) {
        if (!resolvePartType(part).equals(type)) {
            jtype = resolvePartType(part, context, true);
        } else {
            jtype = parsePackageName(namespace, userPackage) + "." + type;
        }
    }
    return jtype;
}
Also used : QName(javax.xml.namespace.QName) ClassCollector(org.apache.cxf.tools.util.ClassCollector) DataBindingProfile(org.apache.cxf.tools.wsdlto.core.DataBindingProfile)

Aggregations

DataBindingProfile (org.apache.cxf.tools.wsdlto.core.DataBindingProfile)5 InputStream (java.io.InputStream)1 PrintStream (java.io.PrintStream)1 QName (javax.xml.namespace.QName)1 Message (org.apache.cxf.common.i18n.Message)1 ToolException (org.apache.cxf.tools.common.ToolException)1 ClassCollector (org.apache.cxf.tools.util.ClassCollector)1 FrontEndProfile (org.apache.cxf.tools.wsdlto.core.FrontEndProfile)1