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))));
}
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))));
}
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)))));
}
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))));
}
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);
});
}
}
Aggregations