Search in sources :

Example 1 with XmlDslModel

use of org.mule.runtime.api.meta.model.XmlDslModel in project mule by mulesoft.

the class JavaXmlDeclarationEnricherTestCase method enrichWithCustomNamespaceValue.

@Test
public void enrichWithCustomNamespaceValue() {
    extensionDeclarer.named(EXTENSION_NAME).onVersion(EXTENSION_VERSION);
    XmlDslModel dslModel = enrich(DefaultXmlExtension.class);
    assertThat(dslModel, is(notNullValue()));
    assertThat(dslModel.getSchemaVersion(), is(EXTENSION_VERSION));
    assertThat(dslModel.getPrefix(), is(NAMESPACE));
    assertThat(dslModel.getNamespace(), equalTo(String.format(DEFAULT_NAMESPACE_LOCATION_MASK, NAMESPACE)));
    assertThat(dslModel.getXsdFileName(), is(String.format(XSD_FILENAME_MASK, NAMESPACE)));
    assertThat(dslModel.getSchemaLocation(), is(String.format(DEFAULT_SCHEMA_LOCATION_MASK, String.format(DEFAULT_NAMESPACE_LOCATION_MASK, NAMESPACE), String.format(XSD_FILENAME_MASK, NAMESPACE))));
}
Also used : XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 2 with XmlDslModel

use of org.mule.runtime.api.meta.model.XmlDslModel in project mule by mulesoft.

the class JavaXmlDeclarationEnricherTestCase method enrichWithDefaultValues.

@Test
public void enrichWithDefaultValues() {
    extensionDeclarer.named(EXTENSION_NAME).onVersion(EXTENSION_VERSION);
    XmlDslModel dslModel = enrich(NoXmlSupport.class);
    assertThat(dslModel, is(notNullValue()));
    assertThat(dslModel.getSchemaVersion(), is(EXTENSION_VERSION));
    assertThat(dslModel.getPrefix(), is(EXTENSION_HYPHENAZED_NAME));
    assertThat(dslModel.getNamespace(), equalTo(String.format(DEFAULT_NAMESPACE_LOCATION_MASK, EXTENSION_HYPHENAZED_NAME)));
    assertThat(dslModel.getXsdFileName(), is(String.format(XSD_FILENAME_MASK, EXTENSION_HYPHENAZED_NAME)));
    assertThat(dslModel.getSchemaLocation(), is(String.format(DEFAULT_SCHEMA_LOCATION_MASK, String.format(DEFAULT_NAMESPACE_LOCATION_MASK, EXTENSION_HYPHENAZED_NAME), String.format(XSD_FILENAME_MASK, EXTENSION_HYPHENAZED_NAME))));
}
Also used : XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 3 with XmlDslModel

use of org.mule.runtime.api.meta.model.XmlDslModel in project mule by mulesoft.

the class JavaXmlDeclarationEnricherTestCase method enrichWithCustomSchemaLocationValue.

@Test
public void enrichWithCustomSchemaLocationValue() {
    extensionDeclarer.named(EXTENSION).onVersion(EXTENSION_VERSION);
    XmlDslModel dslModel = enrich(CustomSchemaLocationXmlExtension.class);
    assertThat(dslModel, is(notNullValue()));
    assertThat(dslModel.getSchemaVersion(), is(EXTENSION_VERSION));
    assertThat(dslModel.getPrefix(), is(EXTENSION.toLowerCase()));
    assertThat(dslModel.getNamespace(), equalTo(NAMESPACE_LOCATION));
    assertThat(dslModel.getXsdFileName(), is(String.format(XSD_FILENAME_MASK, hyphenize(EXTENSION))));
    assertThat(dslModel.getSchemaLocation(), is(String.format(DEFAULT_SCHEMA_LOCATION_MASK, NAMESPACE_LOCATION, String.format(XSD_FILENAME_MASK, hyphenize(EXTENSION)))));
}
Also used : XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 4 with XmlDslModel

use of org.mule.runtime.api.meta.model.XmlDslModel in project mule by mulesoft.

the class JavaXmlDeclarationEnricherTestCase method enrichWithCustomValues.

@Test
public void enrichWithCustomValues() {
    extensionDeclarer.named(EXTENSION_NAME).onVersion(EXTENSION_VERSION);
    XmlDslModel dslModel = enrich(XmlSupport.class);
    assertThat(dslModel, is(notNullValue()));
    assertThat(dslModel.getSchemaVersion(), is(EXTENSION_VERSION));
    assertThat(dslModel.getPrefix(), is(NAMESPACE));
    assertThat(dslModel.getNamespace(), is(NAMESPACE_LOCATION));
    assertThat(dslModel.getXsdFileName(), is(String.format(XSD_FILENAME_MASK, NAMESPACE)));
    assertThat(dslModel.getSchemaLocation(), is(String.format(DEFAULT_SCHEMA_LOCATION_MASK, NAMESPACE_LOCATION, String.format(XSD_FILENAME_MASK, NAMESPACE))));
}
Also used : XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 5 with XmlDslModel

use of org.mule.runtime.api.meta.model.XmlDslModel in project mule by mulesoft.

the class DefaultExtensionBuildingDefinitionProvider method registerExtensionParsers.

private void registerExtensionParsers(ExtensionModel extensionModel) {
    XmlDslModel xmlDslModel = extensionModel.getXmlDslModel();
    final ExtensionParsingContext parsingContext = createParsingContext(extensionModel);
    final Builder definitionBuilder = new Builder().withNamespace(xmlDslModel.getPrefix());
    final DslSyntaxResolver dslSyntaxResolver = DslSyntaxResolver.getDefault(extensionModel, DslResolvingContext.getDefault(extensions));
    if (extensionModel.getModelProperty(CustomBuildingDefinitionProviderModelProperty.class).isPresent()) {
        return;
    }
    if (extensionModel.getModelProperty(XmlExtensionModelProperty.class).isPresent()) {
        registerXmlExtensionParsers(definitionBuilder, extensionModel, dslSyntaxResolver);
    } else {
        final ClassLoader extensionClassLoader = getClassLoader(extensionModel);
        withContextClassLoader(extensionClassLoader, () -> {
            ReflectionCache reflectionCache = new ReflectionCache();
            new IdempotentExtensionWalker() {

                @Override
                public void onConfiguration(ConfigurationModel model) {
                    parseWith(new ConfigurationDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
                }

                @Override
                protected void onConstruct(ConstructModel model) {
                    parseWith(new ConstructDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
                }

                @Override
                public void onOperation(OperationModel model) {
                    parseWith(new OperationDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
                }

                @Override
                public void onConnectionProvider(ConnectionProviderModel model) {
                    parseWith(new ConnectionProviderDefinitionParser(definitionBuilder, model, extensionModel, dslSyntaxResolver, parsingContext));
                }

                @Override
                public void onSource(SourceModel model) {
                    parseWith(new SourceDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
                }

                @Override
                protected void onParameter(ParameterGroupModel groupModel, ParameterModel model) {
                    registerTopLevelParameter(model.getType(), definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
                }
            }.walk(extensionModel);
            registerExportedTypesTopLevelParsers(extensionModel, definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
            registerSubTypes(definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
        });
    }
}
Also used : ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) Builder(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition.Builder) ModuleOperationMessageProcessorChainBuilder(org.mule.runtime.core.internal.processor.chain.ModuleOperationMessageProcessorChainBuilder) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) CustomBuildingDefinitionProviderModelProperty(org.mule.runtime.core.internal.extension.CustomBuildingDefinitionProviderModelProperty) ConnectionProviderDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.connection.ConnectionProviderDefinitionParser) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) XmlExtensionModelProperty(org.mule.runtime.extension.api.property.XmlExtensionModelProperty) ConstructDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.construct.ConstructDefinitionParser) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) SourceDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.source.SourceDefinitionParser) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) MuleExtensionUtils.getClassLoader(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.getClassLoader) ClassUtils.withContextClassLoader(org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader) ConfigurationDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.config.ConfigurationDefinitionParser) 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) OperationDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.operation.OperationDefinitionParser)

Aggregations

XmlDslModel (org.mule.runtime.api.meta.model.XmlDslModel)10 Test (org.junit.Test)4 SmallTest (org.mule.tck.size.SmallTest)4 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)3 ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)3 TreeSet (java.util.TreeSet)2 DslSyntaxResolver (org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver)2 XmlExtensionModelProperty (org.mule.runtime.extension.api.property.XmlExtensionModelProperty)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Sets (com.google.common.collect.Sets)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 Boolean.parseBoolean (java.lang.Boolean.parseBoolean)1 String.format (java.lang.String.format)1 String.join (java.lang.String.join)1 Thread.currentThread (java.lang.Thread.currentThread)1 URL (java.net.URL)1 Collections (java.util.Collections)1 Collections.singletonList (java.util.Collections.singletonList)1