Search in sources :

Example 1 with SchemaBuilder

use of org.mule.runtime.module.extension.internal.capability.xml.schema.builder.SchemaBuilder in project mule by mulesoft.

the class DefaultExtensionSchemaGenerator method generate.

/**
 * {@inheritDoc}
 */
@Override
public String generate(ExtensionModel extensionModel, DslResolvingContext dslContext) {
    XmlDslModel xmlDslModel = extensionModel.getXmlDslModel();
    validate(extensionModel, xmlDslModel);
    SchemaBuilder schemaBuilder = SchemaBuilder.newSchema(extensionModel, xmlDslModel, dslContext);
    new IdempotentExtensionWalker() {

        @Override
        public void onConfiguration(ConfigurationModel model) {
            schemaBuilder.registerConfigElement(model);
        }

        @Override
        protected void onConstruct(ConstructModel model) {
            schemaBuilder.registerOperation(model);
        }

        @Override
        public void onOperation(OperationModel model) {
            schemaBuilder.registerOperation(model);
        }

        @Override
        public void onConnectionProvider(ConnectionProviderModel model) {
            schemaBuilder.registerConnectionProviderElement(model);
        }

        @Override
        public void onSource(SourceModel model) {
            schemaBuilder.registerMessageSource(model);
        }
    }.walk(extensionModel);
    schemaBuilder.registerEnums();
    // Make sure the XML libs use the container classloader internally
    return withContextClassLoader(DefaultExtensionSchemaGenerator.class.getClassLoader(), () -> renderSchema(schemaBuilder.build()));
}
Also used : SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) SchemaBuilder(org.mule.runtime.module.extension.internal.capability.xml.schema.builder.SchemaBuilder) XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) IdempotentExtensionWalker(org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Aggregations

XmlDslModel (org.mule.runtime.api.meta.model.XmlDslModel)1 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)1 ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)1 ConstructModel (org.mule.runtime.api.meta.model.construct.ConstructModel)1 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)1 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)1 IdempotentExtensionWalker (org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker)1 SchemaBuilder (org.mule.runtime.module.extension.internal.capability.xml.schema.builder.SchemaBuilder)1