com.sun.tools.xjc.api.SchemaCompiler Java Examples

The following examples show how to use com.sun.tools.xjc.api.SchemaCompiler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLImporter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * Import the Types from the WSDL definition using the same strategy that Cxf uses taking advantage of JAXB
 */
protected 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);
  }
}
 
Example #2
Source File: WSDLImporter.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Import the Types from the WSDL definition using the same strategy that Cxf uses taking advantage of JAXB
 */
protected 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);
    }
}
 
Example #3
Source File: CxfWSDLImporter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example #4
Source File: FromXmlConfig.java    From kafka-connect-transform-xml with Apache License 2.0 5 votes vote down vote up
public static ConfigDef config() {
  SchemaCompiler schemaCompiler = XJC.createSchemaCompiler();
  Options options = schemaCompiler.getOptions();

  return new ConfigDef()
      .define(
          ConfigKeyBuilder.of(SCHEMA_PATH_CONFIG, ConfigDef.Type.LIST)
              .documentation(SCHEMA_PATH_DOC)
              .importance(ConfigDef.Importance.HIGH)
              .validator(new ValidUrl())
              .build()
      ).define(
          ConfigKeyBuilder.of(PACKAGE_CONFIG, ConfigDef.Type.STRING)
              .documentation(PACKAGE_DOC)
              .importance(ConfigDef.Importance.HIGH)
              .defaultValue(FromXmlConfig.class.getPackage().getName() + ".model")
              .build()
      ).define(
          ConfigKeyBuilder.of(XJC_OPTIONS_STRICT_CHECK_CONFIG, ConfigDef.Type.BOOLEAN)
              .documentation(XJC_OPTIONS_STRICT_CHECK_DOC)
              .importance(ConfigDef.Importance.LOW)
              .defaultValue(options.strictCheck)
              .build()
      ).define(
          ConfigKeyBuilder.of(XJC_OPTIONS_AUTOMATIC_NAME_CONFLICT_RESOLUTION_ENABLED_CONFIG, ConfigDef.Type.BOOLEAN)
              .documentation(XJC_OPTIONS_AUTOMATIC_NAME_CONFLICT_RESOLUTION_ENABLED_DOC)
              .importance(ConfigDef.Importance.LOW)
              .defaultValue(options.automaticNameConflictResolution)
              .build()
      ).define(
          ConfigKeyBuilder.of(XJC_OPTIONS_VERBOSE_CONFIG, ConfigDef.Type.BOOLEAN)
              .documentation(XJC_OPTIONS_VERBOSE_DOC)
              .importance(ConfigDef.Importance.LOW)
              .defaultValue(options.verbose)
              .build()
      );
}
 
Example #5
Source File: CxfWSDLImporter.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #6
Source File: JAXBDataBinding.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void parseSchemas(SchemaCompiler schemaCompiler) {
    for (String ns : context.getNamespacePackageMap().keySet()) {
        File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, context.mapPackageName(ns));
        try {
            InputSource ins = new InputSource(file.toURI().toString());
            schemaCompiler.parseSchema(ins);
        } finally {
            FileUtils.delete(file);
        }
    }

    if (context.getPackageName() != null) {
        schemaCompiler.setDefaultPackageName(context.getPackageName());
    }
}
 
Example #7
Source File: JAXBDataBinding.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void hackInNewInternalizationLogic(SchemaCompiler schemaCompiler,
                                           final OASISCatalogManager catalog,
                                           Options opts) {
    try {
        Field f = schemaCompiler.getClass().getDeclaredField("forest");
        ReflectionUtil.setAccessible(f);
        XMLSchemaInternalizationLogic logic = new XMLSchemaInternalizationLogic() {
            public XMLFilterImpl createExternalReferenceFinder(DOMForest parent) {
                return new ReferenceFinder(parent, catalog);
            }
        };

        Constructor<DOMForest> c = null;
        DOMForest forest = null;

        try {
            c = DOMForest.class.getConstructor(InternalizationLogic.class, Options.class);
            forest = c.newInstance(logic, opts);
        } catch (Throwable t) {
            c = DOMForest.class.getConstructor(InternalizationLogic.class);
            forest = c.newInstance(logic);
        }
        forest.setErrorHandler((ErrorReceiver)schemaCompiler);
        f.set(schemaCompiler, forest);
    } catch (Throwable ex)  {
        //ignore
    }
}
 
Example #8
Source File: JAXBDataBinding.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addSchemasForServiceInfos(OASISCatalogManager catalog,
                                       List<ServiceInfo> serviceList,
                                      Options opts,
                                      SchemaCompiler schemaCompiler,
                                      SchemaCollection schemaCollection) {
    Set<String> ids = new HashSet<>();
    for (ServiceInfo si : serviceList) {
        for (SchemaInfo sci : si.getSchemas()) {
            String key = sci.getSystemId();
            if (ids.contains(key)) {
                continue;
            }
            ids.add(key);
            Element ele = sci.getElement();
            if (context.fullValidateWSDL()) {
                validateSchema(ele, sci.getSystemId(), catalog, schemaCollection);
            }
            ele = removeImportElement(ele, key, catalog);
            InputSource is = new InputSource((InputStream)null);
            //key = key.replaceFirst("#types[0-9]+$", "");
            is.setSystemId(key);
            is.setPublicId(key);
            opts.addGrammar(is);
            try {
                XMLStreamReader reader = createNoCDATAReader(StaxUtils.createXMLStreamReader(ele, key));
                schemaCompiler.parseSchema(key, reader);
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
    }

}
 
Example #9
Source File: CxfWSDLImporter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #10
Source File: WSDLImporter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected 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;
}
 
Example #11
Source File: CxfWSDLImporter.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #12
Source File: WSDLImporter.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected 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;
}
 
Example #13
Source File: JAXBDataBinding.java    From cxf with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private Options getOptions(SchemaCompiler schemaCompiler) throws ToolException {
    return schemaCompiler.getOptions();
}
 
Example #14
Source File: WsimportOptionsEx.java    From mwsc with MIT License 4 votes vote down vote up
@Override
public SchemaCompiler getSchemaCompiler() {
    schemaCompilerEx.setTargetVersion(SpecVersion.parse(target.getVersion()));
    schemaCompilerEx.setEntityResolver(entityResolver);
    return schemaCompilerEx;
}