Search in sources :

Example 26 with Reference

use of org.mule.runtime.api.util.Reference in project mule by mulesoft.

the class ProcessorChainExecutorTestCase method testDoProcessOnErrorMessagingException.

@Test
public void testDoProcessOnErrorMessagingException() throws InterruptedException, MuleException {
    final String ERROR_PAYLOAD = "ERROR_PAYLOAD";
    when(chain.apply(any())).thenReturn(error(new MessagingException(createStaticMessage(""), getEventBuilder().message(of(ERROR_PAYLOAD)).build())));
    ImmutableProcessorChainExecutor chainExecutor = new ImmutableProcessorChainExecutor(coreEvent, chain);
    AtomicInteger successCalls = new AtomicInteger(0);
    AtomicInteger errorCalls = new AtomicInteger(0);
    Reference<Event> errorEvent = new Reference<>();
    doProcessAndWait(chainExecutor, r -> successCalls.incrementAndGet(), (t, r) -> {
        errorCalls.incrementAndGet();
        errorEvent.set(((EventedResult) r).getEvent());
    });
    assertThat(successCalls.get(), is(0));
    assertThat(errorCalls.get(), is(1));
    assertThat(errorEvent.get().getMessage().getPayload().getValue(), is(ERROR_PAYLOAD));
}
Also used : MessagingException(org.mule.runtime.core.internal.exception.MessagingException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Reference(org.mule.runtime.api.util.Reference) Event(org.mule.runtime.api.event.Event) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Example 27 with Reference

use of org.mule.runtime.api.util.Reference in project mule by mulesoft.

the class DefaultXmlArtifactDeclarationLoader method declareElement.

private void declareElement(final ConfigLine configLine, final ArtifactDeclarer artifactDeclarer) {
    final ExtensionModel ownerExtension = getExtensionModel(configLine);
    final ElementDeclarer extensionElementsDeclarer = forExtension(ownerExtension.getName());
    final DslSyntaxResolver dsl = resolvers.get(getNamespace(configLine));
    Reference<Boolean> alreadyDeclared = new Reference<>(false);
    new ExtensionWalker() {

        @Override
        protected void onConstruct(HasConstructModels owner, ConstructModel model) {
            declareComponentModel(configLine, model, extensionElementsDeclarer::newConstruct).ifPresent(declarer -> {
                getDeclaredName(configLine).ifPresent(((ConstructElementDeclarer) declarer)::withRefName);
                artifactDeclarer.withGlobalElement((GlobalElementDeclaration) declarer.getDeclaration());
                alreadyDeclared.set(true);
                stop();
            });
        }

        @Override
        protected void onConfiguration(ConfigurationModel model) {
            final DslElementSyntax elementDsl = dsl.resolve(model);
            if (elementDsl.getElementName().equals(configLine.getIdentifier())) {
                ConfigurationElementDeclarer configurationDeclarer = extensionElementsDeclarer.newConfiguration(model.getName());
                getDeclaredName(configLine).ifPresent(configurationDeclarer::withRefName);
                Map<String, SimpleConfigAttribute> attributes = configLine.getConfigAttributes().values().stream().filter(a -> !a.getName().equals(NAME_ATTRIBUTE_NAME)).collect(toMap(SimpleConfigAttribute::getName, a -> a));
                List<ConfigLine> configComplexParameters = configLine.getChildren().stream().filter(config -> declareAsConnectionProvider(ownerExtension, model, configurationDeclarer, config, extensionElementsDeclarer)).collect(toList());
                declareParameterizedComponent(model, elementDsl, configurationDeclarer, attributes, configComplexParameters);
                artifactDeclarer.withGlobalElement(configurationDeclarer.getDeclaration());
                alreadyDeclared.set(true);
                stop();
            }
        }
    }.walk(ownerExtension);
    if (!alreadyDeclared.get()) {
        ownerExtension.getTypes().stream().filter(type -> dsl.resolve(type).map(typeDsl -> typeDsl.getElementName().equals(configLine.getIdentifier())).orElse(false)).findFirst().ifPresent(type -> {
            TopLevelParameterDeclarer topLevelParameter = extensionElementsDeclarer.newGlobalParameter(configLine.getIdentifier());
            getDeclaredName(configLine).ifPresent(topLevelParameter::withRefName);
            type.accept(getParameterDeclarerVisitor(configLine, dsl.resolve(type).get(), value -> topLevelParameter.withValue((ParameterObjectValue) value)));
            artifactDeclarer.withGlobalElement(topLevelParameter.getDeclaration());
        });
    }
}
Also used : Arrays(java.util.Arrays) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) SimpleConfigAttribute(org.mule.runtime.config.api.dsl.processor.SimpleConfigAttribute) TLS_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TLS_PARAMETER_NAME) MuleApplicationClassLoader.resolveContextArtifactPluginClassLoaders(org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoader.resolveContextArtifactPluginClassLoaders) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) EXPIRATION_POLICY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.EXPIRATION_POLICY_ELEMENT_IDENTIFIER) REDELIVERY_POLICY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.REDELIVERY_POLICY_ELEMENT_IDENTIFIER) ArrayType(org.mule.metadata.api.model.ArrayType) Document(org.w3c.dom.Document) Map(java.util.Map) ParameterSimpleValue(org.mule.runtime.app.declaration.api.fluent.ParameterSimpleValue) ParameterGroupElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ParameterGroupElementDeclarer) MetadataTypeUtils.getLocalPart(org.mule.metadata.api.utils.MetadataTypeUtils.getLocalPart) ElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer) RECONNECT_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECT_ELEMENT_IDENTIFIER) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) ObjectType(org.mule.metadata.api.model.ObjectType) ElementDeclarer.newObjectValue(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer.newObjectValue) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) POOLING_PROFILE_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.POOLING_PROFILE_PARAMETER_NAME) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) NON_REPEATABLE_BYTE_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.NON_REPEATABLE_BYTE_STREAM_ALIAS) XmlArtifactDeclarationLoader(org.mule.runtime.config.internal.dsl.model.XmlArtifactDeclarationLoader) ExtensionModelUtils.isInfrastructure(org.mule.runtime.extension.api.util.ExtensionModelUtils.isInfrastructure) MetadataType(org.mule.metadata.api.model.MetadataType) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) CONFIG_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.CONFIG_ATTRIBUTE_NAME) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) REPEATABLE_FILE_STORE_BYTES_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_FILE_STORE_BYTES_STREAM_ALIAS) RouteElementDeclaration(org.mule.runtime.app.declaration.api.RouteElementDeclaration) VALUE_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.VALUE_ATTRIBUTE_NAME) ParameterSimpleValue.cdata(org.mule.runtime.app.declaration.api.fluent.ParameterSimpleValue.cdata) ConfigurationElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConfigurationElementDeclarer) ParameterListValue(org.mule.runtime.app.declaration.api.fluent.ParameterListValue) ParameterSimpleValue.plain(org.mule.runtime.app.declaration.api.fluent.ParameterSimpleValue.plain) EXPIRATION_POLICY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.EXPIRATION_POLICY_PARAMETER_NAME) ConnectionElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConnectionElementDeclarer) ElementDeclarer.newListValue(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer.newListValue) XmlConfigurationDocumentLoader.noValidationDocumentLoader(org.mule.runtime.config.api.XmlConfigurationDocumentLoader.noValidationDocumentLoader) ConstructElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConstructElementDeclarer) GlobalElementDeclaration(org.mule.runtime.app.declaration.api.GlobalElementDeclaration) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) ParameterValue(org.mule.runtime.app.declaration.api.ParameterValue) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) RECONNECTION_CONFIG_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.RECONNECTION_CONFIG_PARAMETER_NAME) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) STREAMING_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.STREAMING_STRATEGY_PARAMETER_NAME) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) Reference(org.mule.runtime.api.util.Reference) ParameterizedBuilder(org.mule.runtime.app.declaration.api.fluent.ParameterizedBuilder) ComponentElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ComponentElementDeclarer) ElementDeclarer.forExtension(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer.forExtension) ExtensionMetadataTypeUtils.getId(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getId) TLS_REVOCATION_CHECK_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.TLS_REVOCATION_CHECK_ELEMENT_IDENTIFIER) RECONNECT_FOREVER_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECT_FOREVER_ELEMENT_IDENTIFIER) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) HasNestedComponentDeclarer(org.mule.runtime.app.declaration.api.fluent.HasNestedComponentDeclarer) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ComposableModel(org.mule.runtime.api.meta.model.ComposableModel) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) Collectors.toMap(java.util.stream.Collectors.toMap) XmlApplicationParser(org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationParser) ArtifactDeclarer(org.mule.runtime.app.declaration.api.fluent.ArtifactDeclarer) KEY_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.KEY_ATTRIBUTE_NAME) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) REPEATABLE_IN_MEMORY_BYTES_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_IN_MEMORY_BYTES_STREAM_ALIAS) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) TLS_CONTEXT_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.TLS_CONTEXT_ELEMENT_IDENTIFIER) REDELIVERY_POLICY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.REDELIVERY_POLICY_PARAMETER_NAME) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) CONNECTION(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel.CONNECTION) RECONNECTION_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.RECONNECTION_STRATEGY_PARAMETER_NAME) NAME_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.NAME_ATTRIBUTE_NAME) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) HasOperationModels(org.mule.runtime.api.meta.model.operation.HasOperationModels) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) Optional(java.util.Optional) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) HasConstructModels(org.mule.runtime.api.meta.model.construct.HasConstructModels) POOLING_PROFILE_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.POOLING_PROFILE_ELEMENT_IDENTIFIER) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) RouteElementDeclarer(org.mule.runtime.app.declaration.api.fluent.RouteElementDeclarer) HashMap(java.util.HashMap) Function(java.util.function.Function) ArtifactDeclaration(org.mule.runtime.app.declaration.api.ArtifactDeclaration) XmlApplicationServiceRegistry(org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationServiceRegistry) ParameterObjectValue(org.mule.runtime.app.declaration.api.fluent.ParameterObjectValue) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) ElementDeclarer.newParameterGroup(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer.newParameterGroup) ParameterizedElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ParameterizedElementDeclarer) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) TopLevelParameterDeclarer(org.mule.runtime.app.declaration.api.fluent.TopLevelParameterDeclarer) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) IS_CDATA(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler.IS_CDATA) ComponentElementDeclaration(org.mule.runtime.app.declaration.api.ComponentElementDeclaration) ExtensibleTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.ExtensibleTypeAnnotation) HasSourceModels(org.mule.runtime.api.meta.model.source.HasSourceModels) InputStream(java.io.InputStream) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ConfigurationElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConfigurationElementDeclarer) SimpleConfigAttribute(org.mule.runtime.config.api.dsl.processor.SimpleConfigAttribute) Reference(org.mule.runtime.api.util.Reference) TopLevelParameterDeclarer(org.mule.runtime.app.declaration.api.fluent.TopLevelParameterDeclarer) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) ConstructElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConstructElementDeclarer) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) ParameterGroupElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ParameterGroupElementDeclarer) ElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer) ConfigurationElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConfigurationElementDeclarer) ConnectionElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConnectionElementDeclarer) ConstructElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConstructElementDeclarer) ComponentElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ComponentElementDeclarer) RouteElementDeclarer(org.mule.runtime.app.declaration.api.fluent.RouteElementDeclarer) ParameterizedElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ParameterizedElementDeclarer) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) HasConstructModels(org.mule.runtime.api.meta.model.construct.HasConstructModels) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) GlobalElementDeclaration(org.mule.runtime.app.declaration.api.GlobalElementDeclaration) Map(java.util.Map) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) Collectors.toMap(java.util.stream.Collectors.toMap) HashMap(java.util.HashMap)

Example 28 with Reference

use of org.mule.runtime.api.util.Reference in project mule by mulesoft.

the class DefaultXmlArtifactDeclarationLoader method declareComposableModel.

private void declareComposableModel(ComposableModel model, DslElementSyntax elementDsl, ConfigLine containerConfig, HasNestedComponentDeclarer declarer) {
    containerConfig.getChildren().forEach((ConfigLine child) -> {
        ExtensionModel extensionModel = getExtensionModel(child);
        ElementDeclarer extensionElementsDeclarer = forExtension(extensionModel.getName());
        Reference<Boolean> componentFound = new Reference<>(false);
        getComponentDeclaringWalker(declaration -> {
            declarer.withComponent(declaration);
            componentFound.set(true);
        }, child, extensionElementsDeclarer).walk(extensionModel);
        if (!componentFound.get()) {
            declareRoute(model, elementDsl, child, extensionElementsDeclarer).ifPresent(declarer::withComponent);
        }
    });
}
Also used : Arrays(java.util.Arrays) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) SimpleConfigAttribute(org.mule.runtime.config.api.dsl.processor.SimpleConfigAttribute) TLS_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TLS_PARAMETER_NAME) MuleApplicationClassLoader.resolveContextArtifactPluginClassLoaders(org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoader.resolveContextArtifactPluginClassLoaders) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) EXPIRATION_POLICY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.EXPIRATION_POLICY_ELEMENT_IDENTIFIER) REDELIVERY_POLICY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.REDELIVERY_POLICY_ELEMENT_IDENTIFIER) ArrayType(org.mule.metadata.api.model.ArrayType) Document(org.w3c.dom.Document) Map(java.util.Map) ParameterSimpleValue(org.mule.runtime.app.declaration.api.fluent.ParameterSimpleValue) ParameterGroupElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ParameterGroupElementDeclarer) MetadataTypeUtils.getLocalPart(org.mule.metadata.api.utils.MetadataTypeUtils.getLocalPart) ElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer) RECONNECT_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECT_ELEMENT_IDENTIFIER) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) ObjectType(org.mule.metadata.api.model.ObjectType) ElementDeclarer.newObjectValue(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer.newObjectValue) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) POOLING_PROFILE_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.POOLING_PROFILE_PARAMETER_NAME) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) NON_REPEATABLE_BYTE_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.NON_REPEATABLE_BYTE_STREAM_ALIAS) XmlArtifactDeclarationLoader(org.mule.runtime.config.internal.dsl.model.XmlArtifactDeclarationLoader) ExtensionModelUtils.isInfrastructure(org.mule.runtime.extension.api.util.ExtensionModelUtils.isInfrastructure) MetadataType(org.mule.metadata.api.model.MetadataType) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) CONFIG_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.CONFIG_ATTRIBUTE_NAME) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) REPEATABLE_FILE_STORE_BYTES_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_FILE_STORE_BYTES_STREAM_ALIAS) RouteElementDeclaration(org.mule.runtime.app.declaration.api.RouteElementDeclaration) VALUE_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.VALUE_ATTRIBUTE_NAME) ParameterSimpleValue.cdata(org.mule.runtime.app.declaration.api.fluent.ParameterSimpleValue.cdata) ConfigurationElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConfigurationElementDeclarer) ParameterListValue(org.mule.runtime.app.declaration.api.fluent.ParameterListValue) ParameterSimpleValue.plain(org.mule.runtime.app.declaration.api.fluent.ParameterSimpleValue.plain) EXPIRATION_POLICY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.EXPIRATION_POLICY_PARAMETER_NAME) ConnectionElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConnectionElementDeclarer) ElementDeclarer.newListValue(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer.newListValue) XmlConfigurationDocumentLoader.noValidationDocumentLoader(org.mule.runtime.config.api.XmlConfigurationDocumentLoader.noValidationDocumentLoader) ConstructElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConstructElementDeclarer) GlobalElementDeclaration(org.mule.runtime.app.declaration.api.GlobalElementDeclaration) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) ParameterValue(org.mule.runtime.app.declaration.api.ParameterValue) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) RECONNECTION_CONFIG_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.RECONNECTION_CONFIG_PARAMETER_NAME) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) STREAMING_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.STREAMING_STRATEGY_PARAMETER_NAME) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) Reference(org.mule.runtime.api.util.Reference) ParameterizedBuilder(org.mule.runtime.app.declaration.api.fluent.ParameterizedBuilder) ComponentElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ComponentElementDeclarer) ElementDeclarer.forExtension(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer.forExtension) ExtensionMetadataTypeUtils.getId(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getId) TLS_REVOCATION_CHECK_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.TLS_REVOCATION_CHECK_ELEMENT_IDENTIFIER) RECONNECT_FOREVER_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECT_FOREVER_ELEMENT_IDENTIFIER) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) HasNestedComponentDeclarer(org.mule.runtime.app.declaration.api.fluent.HasNestedComponentDeclarer) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ComposableModel(org.mule.runtime.api.meta.model.ComposableModel) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) Collectors.toMap(java.util.stream.Collectors.toMap) XmlApplicationParser(org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationParser) ArtifactDeclarer(org.mule.runtime.app.declaration.api.fluent.ArtifactDeclarer) KEY_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.KEY_ATTRIBUTE_NAME) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) REPEATABLE_IN_MEMORY_BYTES_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_IN_MEMORY_BYTES_STREAM_ALIAS) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) TLS_CONTEXT_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.TLS_CONTEXT_ELEMENT_IDENTIFIER) REDELIVERY_POLICY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.REDELIVERY_POLICY_PARAMETER_NAME) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) CONNECTION(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel.CONNECTION) RECONNECTION_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.RECONNECTION_STRATEGY_PARAMETER_NAME) NAME_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.NAME_ATTRIBUTE_NAME) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) HasOperationModels(org.mule.runtime.api.meta.model.operation.HasOperationModels) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) Optional(java.util.Optional) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) HasConstructModels(org.mule.runtime.api.meta.model.construct.HasConstructModels) POOLING_PROFILE_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.POOLING_PROFILE_ELEMENT_IDENTIFIER) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) RouteElementDeclarer(org.mule.runtime.app.declaration.api.fluent.RouteElementDeclarer) HashMap(java.util.HashMap) Function(java.util.function.Function) ArtifactDeclaration(org.mule.runtime.app.declaration.api.ArtifactDeclaration) XmlApplicationServiceRegistry(org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationServiceRegistry) ParameterObjectValue(org.mule.runtime.app.declaration.api.fluent.ParameterObjectValue) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) ElementDeclarer.newParameterGroup(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer.newParameterGroup) ParameterizedElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ParameterizedElementDeclarer) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) TopLevelParameterDeclarer(org.mule.runtime.app.declaration.api.fluent.TopLevelParameterDeclarer) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) IS_CDATA(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler.IS_CDATA) ComponentElementDeclaration(org.mule.runtime.app.declaration.api.ComponentElementDeclaration) ExtensibleTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.ExtensibleTypeAnnotation) HasSourceModels(org.mule.runtime.api.meta.model.source.HasSourceModels) InputStream(java.io.InputStream) Reference(org.mule.runtime.api.util.Reference) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) ParameterGroupElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ParameterGroupElementDeclarer) ElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer) ConfigurationElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConfigurationElementDeclarer) ConnectionElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConnectionElementDeclarer) ConstructElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ConstructElementDeclarer) ComponentElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ComponentElementDeclarer) RouteElementDeclarer(org.mule.runtime.app.declaration.api.fluent.RouteElementDeclarer) ParameterizedElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ParameterizedElementDeclarer)

Example 29 with Reference

use of org.mule.runtime.api.util.Reference in project mule by mulesoft.

the class DefaultXmlDslElementModelConverter method writeApplicationElement.

private void writeApplicationElement(Element element, DslElementModel<?> elementModel, Element parentNode) {
    populateInfrastructureConfiguration(element, elementModel);
    if (elementModel.getContainedElements().isEmpty() && elementModel.getValue().isPresent()) {
        setTextContentElement(element, elementModel, parentNode);
        return;
    }
    elementModel.getContainedElements().stream().filter(c -> !isInfrastructure(c)).forEach(inner -> {
        DslElementSyntax innerDsl = inner.getDsl();
        Reference<Boolean> configured = new Reference<>(false);
        if (innerDsl.supportsAttributeDeclaration() && inner.getValue().isPresent()) {
            getCustomizedValue(inner).ifPresent(value -> {
                configured.set(true);
                element.setAttribute(innerDsl.getAttributeName(), value);
            });
        }
        if (!configured.get() && innerDsl.supportsChildDeclaration() && inner.isExplicitInDsl()) {
            Element childElement = createElement(innerDsl, inner.getConfiguration());
            if (isEETransform(childElement)) {
                element.appendChild(populateEETransform(inner));
            } else {
                writeApplicationElement(childElement, inner, element);
            }
        }
    });
    if (parentNode != element) {
        parentNode.appendChild(element);
    }
}
Also used : Optional.empty(java.util.Optional.empty) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) EE_NAMESPACE(org.mule.runtime.internal.dsl.DslConstants.EE_NAMESPACE) RECONNECT_FOREVER_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECT_FOREVER_ELEMENT_IDENTIFIER) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) ComponentIdentifier.buildFromStringRepresentation(org.mule.runtime.api.component.ComponentIdentifier.buildFromStringRepresentation) CONFIG_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.CONFIG_ATTRIBUTE_NAME) POOLING_PROFILE_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.POOLING_PROFILE_ELEMENT_IDENTIFIER) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) TLS_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TLS_PARAMETER_NAME) Preconditions.checkArgument(org.mule.runtime.api.util.Preconditions.checkArgument) CORE_NAMESPACE(org.mule.runtime.internal.dsl.DslConstants.CORE_NAMESPACE) XmlDslElementModelConverter(org.mule.runtime.config.api.dsl.model.XmlDslElementModelConverter) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) Attr(org.w3c.dom.Attr) TRANSFORM_IDENTIFIER(org.mule.runtime.config.internal.dsl.declaration.DefaultXmlArtifactDeclarationLoader.TRANSFORM_IDENTIFIER) REDELIVERY_POLICY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.REDELIVERY_POLICY_ELEMENT_IDENTIFIER) Arrays.asList(java.util.Arrays.asList) Document(org.w3c.dom.Document) TLS_PREFIX(org.mule.runtime.internal.dsl.DslConstants.TLS_PREFIX) TARGET_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TARGET_PARAMETER_NAME) TLS_CONTEXT_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.TLS_CONTEXT_ELEMENT_IDENTIFIER) REDELIVERY_POLICY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.REDELIVERY_POLICY_PARAMETER_NAME) DECLARED_PREFIX(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler.DECLARED_PREFIX) RECONNECTION_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECTION_ELEMENT_IDENTIFIER) Stream.of(java.util.stream.Stream.of) RECONNECTION_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.RECONNECTION_STRATEGY_PARAMETER_NAME) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) POOLING_PROFILE_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.POOLING_PROFILE_PARAMETER_NAME) NAME_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.NAME_ATTRIBUTE_NAME) ExtensionModelUtils(org.mule.runtime.extension.api.util.ExtensionModelUtils) XmlModelUtils.buildSchemaLocation(org.mule.runtime.extension.api.util.XmlModelUtils.buildSchemaLocation) DslElementModel(org.mule.runtime.config.api.dsl.model.DslElementModel) List(java.util.List) Element(org.w3c.dom.Element) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) Reference(org.mule.runtime.api.util.Reference) IS_CDATA(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler.IS_CDATA) MetadataType(org.mule.metadata.api.model.MetadataType) Optional(java.util.Optional) EE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.EE_PREFIX) Reference(org.mule.runtime.api.util.Reference) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) Element(org.w3c.dom.Element)

Aggregations

Reference (org.mule.runtime.api.util.Reference)29 ObjectType (org.mule.metadata.api.model.ObjectType)12 List (java.util.List)11 MetadataType (org.mule.metadata.api.model.MetadataType)11 Optional (java.util.Optional)10 ArrayType (org.mule.metadata.api.model.ArrayType)8 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)8 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)8 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)8 Map (java.util.Map)7 ClassTypeLoader (org.mule.metadata.api.ClassTypeLoader)7 ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)7 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)7 ComponentModel (org.mule.runtime.api.meta.model.ComponentModel)6 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)6 ConstructModel (org.mule.runtime.api.meta.model.construct.ConstructModel)6 String.format (java.lang.String.format)5 Optional.empty (java.util.Optional.empty)5 Collectors.toList (java.util.stream.Collectors.toList)5 ExtensionWalker (org.mule.runtime.api.meta.model.util.ExtensionWalker)5