Search in sources :

Example 1 with S2JJAXBModel

use of com.sun.tools.xjc.api.S2JJAXBModel in project Activiti by Activiti.

the class CxfWSDLImporter method importTypes.

protected void importTypes(Types types) {
    SchemaCompiler compiler = XJC.createSchemaCompiler();
    ErrorListener elForRun = new ConsoleErrorReporter();
    compiler.setErrorListener(elForRun);
    SchemaImpl impl = (SchemaImpl) types.getExtensibilityElements().get(0);
    S2JJAXBModel intermediateModel = this.compileModel(types, compiler, impl.getElement());
    Collection<? extends Mapping> mappings = intermediateModel.getMappings();
    for (Mapping mapping : mappings) {
        this.importStructure(mapping);
    }
}
Also used : ErrorListener(com.sun.tools.xjc.api.ErrorListener) SchemaImpl(com.ibm.wsdl.extensions.schema.SchemaImpl) ConsoleErrorReporter(com.sun.tools.xjc.ConsoleErrorReporter) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel) Mapping(com.sun.tools.xjc.api.Mapping) SchemaCompiler(com.sun.tools.xjc.api.SchemaCompiler)

Example 2 with S2JJAXBModel

use of com.sun.tools.xjc.api.S2JJAXBModel in project Activiti by Activiti.

the class WSDLImporter method compileModel.

private S2JJAXBModel compileModel(Types types, SchemaCompiler compiler, Element rootTypes) {
    Schema schema = (Schema) types.getExtensibilityElements().get(0);
    compiler.parseSchema(schema.getDocumentBaseURI() + "#types1", rootTypes);
    S2JJAXBModel intermediateModel = compiler.bind();
    return intermediateModel;
}
Also used : Schema(javax.wsdl.extensions.schema.Schema) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel)

Example 3 with S2JJAXBModel

use of com.sun.tools.xjc.api.S2JJAXBModel in project Activiti by Activiti.

the class WSDLImporter method importTypes.

/**
   * Import the Types from the WSDL definition using the same strategy that
   * Cxf uses taking advantage of JAXB
   */
private void importTypes(Types types) {
    SchemaCompiler compiler = XJC.createSchemaCompiler();
    ErrorListener elForRun = new ConsoleErrorReporter();
    compiler.setErrorListener(elForRun);
    Element rootTypes = this.getRootTypes();
    this.createDefaultStructures(rootTypes);
    S2JJAXBModel intermediateModel = this.compileModel(types, compiler, rootTypes);
    Collection<? extends Mapping> mappings = intermediateModel.getMappings();
    for (Mapping mapping : mappings) {
        this.importStructure(mapping);
    }
}
Also used : ErrorListener(com.sun.tools.xjc.api.ErrorListener) ConsoleErrorReporter(com.sun.tools.xjc.ConsoleErrorReporter) Element(org.w3c.dom.Element) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel) Mapping(com.sun.tools.xjc.api.Mapping) SchemaCompiler(com.sun.tools.xjc.api.SchemaCompiler)

Example 4 with S2JJAXBModel

use of com.sun.tools.xjc.api.S2JJAXBModel in project Activiti by Activiti.

the class CxfWSDLImporter method compileModel.

protected S2JJAXBModel compileModel(Types types, SchemaCompiler compiler, org.w3c.dom.Element rootTypes) {
    Schema schema = (Schema) types.getExtensibilityElements().get(0);
    compiler.parseSchema(schema.getDocumentBaseURI() + "#types1", rootTypes);
    S2JJAXBModel intermediateModel = compiler.bind();
    return intermediateModel;
}
Also used : Schema(javax.wsdl.extensions.schema.Schema) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel)

Example 5 with S2JJAXBModel

use of com.sun.tools.xjc.api.S2JJAXBModel in project cxf by apache.

the class JAXBDataBinding method generate.

public void generate(ToolContext c) throws ToolException {
    if (!initialized) {
        initialize(c);
    }
    if (rawJaxbModelGenCode == null) {
        return;
    }
    if (c.getErrorListener().getErrorCount() > 0) {
        return;
    }
    try {
        String dir = (String) context.get(ToolConstants.CFG_OUTPUTDIR);
        TypesCodeWriter fileCodeWriter = new TypesCodeWriter(new File(dir), context.getExcludePkgList(), (String) context.get(ToolConstants.CFG_ENCODING), context.get(OutputStreamCreator.class));
        S2JJAXBModel schem2JavaJaxbModel = rawJaxbModelGenCode;
        ClassCollector classCollector = context.get(ClassCollector.class);
        for (JClass cls : schem2JavaJaxbModel.getAllObjectFactories()) {
            classCollector.getTypesPackages().add(cls._package().name());
        }
        JCodeModel jcodeModel = schem2JavaJaxbModel.generateCode(null, null);
        if (!isSuppressCodeGen()) {
            jcodeModel.build(fileCodeWriter);
        }
        context.put(JCodeModel.class, jcodeModel);
        for (String str : fileCodeWriter.getExcludeFileList()) {
            context.getExcludeFileList().add(str);
        }
        return;
    } catch (IOException e) {
        Message msg = new Message("FAIL_TO_GENERATE_TYPES", LOG);
        throw new ToolException(msg, e);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) ClassCollector(org.apache.cxf.tools.util.ClassCollector) JClass(com.sun.codemodel.JClass) OutputStreamCreator(org.apache.cxf.tools.util.OutputStreamCreator) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel) IOException(java.io.IOException) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File) JCodeModel(com.sun.codemodel.JCodeModel)

Aggregations

S2JJAXBModel (com.sun.tools.xjc.api.S2JJAXBModel)5 ConsoleErrorReporter (com.sun.tools.xjc.ConsoleErrorReporter)2 ErrorListener (com.sun.tools.xjc.api.ErrorListener)2 Mapping (com.sun.tools.xjc.api.Mapping)2 SchemaCompiler (com.sun.tools.xjc.api.SchemaCompiler)2 Schema (javax.wsdl.extensions.schema.Schema)2 SchemaImpl (com.ibm.wsdl.extensions.schema.SchemaImpl)1 JClass (com.sun.codemodel.JClass)1 JCodeModel (com.sun.codemodel.JCodeModel)1 File (java.io.File)1 IOException (java.io.IOException)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 OutputStreamCreator (org.apache.cxf.tools.util.OutputStreamCreator)1 Element (org.w3c.dom.Element)1