Search in sources :

Example 16 with ComponentIdentifier

use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.

the class ConfigurationBasedElementModelFactory method handleInfrastructure.

private void handleInfrastructure(final ParameterModel paramModel, final DslElementSyntax paramDsl, final Multimap<ComponentIdentifier, ComponentConfiguration> nested, final Map<String, String> parameters, final DslElementModel.Builder<ParameterGroupModel> groupElementBuilder) {
    switch(paramModel.getName()) {
        case RECONNECTION_CONFIG_PARAMETER_NAME:
            ComponentConfiguration reconnection = getSingleComponentConfiguration(nested, of(newIdentifier(RECONNECTION_CONFIG_PARAMETER_NAME, paramDsl.getPrefix())));
            if (reconnection != null) {
                groupElementBuilder.containing(newElementModel(paramModel, paramDsl, reconnection));
            }
            return;
        case RECONNECTION_STRATEGY_PARAMETER_NAME:
            ComponentIdentifier reconnectId = newIdentifier(RECONNECT_ELEMENT_IDENTIFIER, paramDsl.getPrefix());
            ComponentConfiguration config = nested.containsKey(reconnectId) ? getSingleComponentConfiguration(nested, of(reconnectId)) : getSingleComponentConfiguration(nested, of(newIdentifier(RECONNECT_FOREVER_ELEMENT_IDENTIFIER, paramDsl.getPrefix())));
            if (config != null) {
                groupElementBuilder.containing(newElementModel(paramModel, paramDsl, config));
            }
            return;
        case REDELIVERY_POLICY_PARAMETER_NAME:
            ComponentConfiguration redelivery = getSingleComponentConfiguration(nested, of(newIdentifier(REDELIVERY_POLICY_ELEMENT_IDENTIFIER, paramDsl.getPrefix())));
            if (redelivery != null) {
                groupElementBuilder.containing(newElementModel(paramModel, paramDsl, redelivery));
            }
            return;
        case EXPIRATION_POLICY_PARAMETER_NAME:
            ComponentConfiguration expiration = getSingleComponentConfiguration(nested, of(newIdentifier(EXPIRATION_POLICY_ELEMENT_IDENTIFIER, paramDsl.getPrefix())));
            if (expiration != null) {
                groupElementBuilder.containing(newElementModel(paramModel, paramDsl, expiration));
            }
            return;
        case POOLING_PROFILE_PARAMETER_NAME:
            ComponentConfiguration pooling = getSingleComponentConfiguration(nested, getIdentifier(paramDsl));
            if (pooling != null) {
                groupElementBuilder.containing(newElementModel(paramModel, paramDsl, pooling));
            }
            return;
        case STREAMING_STRATEGY_PARAMETER_NAME:
            Set<ComponentIdentifier> streaming = newHashSet(newIdentifier(NON_REPEATABLE_BYTE_STREAM_ALIAS, CORE_PREFIX), newIdentifier(REPEATABLE_IN_MEMORY_BYTES_STREAM_ALIAS, CORE_PREFIX), newIdentifier(REPEATABLE_FILE_STORE_BYTES_STREAM_ALIAS, EE_PREFIX), newIdentifier(REPEATABLE_IN_MEMORY_OBJECTS_STREAM_ALIAS, CORE_PREFIX), newIdentifier(REPEATABLE_FILE_STORE_OBJECTS_STREAM_ALIAS, EE_PREFIX), newIdentifier(NON_REPEATABLE_OBJECTS_STREAM_ALIAS, CORE_PREFIX));
            streaming.stream().filter(nested::containsKey).findFirst().ifPresent(s -> groupElementBuilder.containing(newElementModel(paramModel, paramDsl, getSingleComponentConfiguration(nested, of(s)))));
            return;
        case TLS_PARAMETER_NAME:
            ComponentConfiguration tls = getSingleComponentConfiguration(nested, getIdentifier(paramDsl));
            if (tls != null) {
                groupElementBuilder.containing(newElementModel(paramModel, paramDsl, tls));
            } else if (!isBlank(parameters.get(TLS_PARAMETER_NAME))) {
                groupElementBuilder.containing(DslElementModel.builder().withModel(paramModel).withDsl(paramDsl).withValue(parameters.get(TLS_PARAMETER_NAME)).build());
            }
            return;
        case SCHEDULING_STRATEGY_PARAMETER_NAME:
            ComponentConfiguration schedulingStrategyWrapper = getSingleComponentConfiguration(nested, of(ComponentIdentifier.builder().name(SCHEDULING_STRATEGY_ELEMENT_IDENTIFIER).namespace(CORE_PREFIX).build()));
            if (schedulingStrategyWrapper != null) {
                DslElementModel.Builder wrapper = DslElementModel.builder().withModel(paramModel).withDsl(paramDsl).withConfig(schedulingStrategyWrapper);
                Iterator<ComponentConfiguration> nestedIt = schedulingStrategyWrapper.getNestedComponents().iterator();
                if (nestedIt.hasNext()) {
                    final ComponentConfiguration strategy = nestedIt.next();
                    final MetadataType type = CRON_STRATEGY_ELEMENT_IDENTIFIER.equals(strategy.getIdentifier().getName()) ? typeLoader.load(CronScheduler.class) : typeLoader.load(FixedFrequencyScheduler.class);
                    dsl.resolve(type).ifPresent(typeDsl -> wrapper.containing(DslElementModel.builder().withModel(type).withDsl(typeDsl).withConfig(strategy).build()));
                }
                groupElementBuilder.containing(wrapper.build());
            }
            return;
    }
}
Also used : InternalComponentConfiguration(org.mule.runtime.dsl.internal.component.config.InternalComponentConfiguration) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) CronScheduler(org.mule.runtime.core.api.source.scheduler.CronScheduler) MetadataType(org.mule.metadata.api.model.MetadataType) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) DslElementModel(org.mule.runtime.config.api.dsl.model.DslElementModel) FixedFrequencyScheduler(org.mule.runtime.core.api.source.scheduler.FixedFrequencyScheduler)

Example 17 with ComponentIdentifier

use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.

the class ConfigurationBasedElementModelFactory method addConnectionProvider.

private DslElementModel.Builder<ConfigurationModel> addConnectionProvider(ConfigurationModel model, DslSyntaxResolver dsl, DslElementModel.Builder<ConfigurationModel> element, ComponentConfiguration configuration) {
    concat(model.getConnectionProviders().stream(), currentExtension.getConnectionProviders().stream()).map(provider -> {
        DslElementSyntax providerDsl = dsl.resolve(provider);
        ComponentIdentifier identifier = getIdentifier(providerDsl).orElse(null);
        return configuration.getNestedComponents().stream().filter(c -> c.getIdentifier().equals(identifier)).findFirst().map(providerConfig -> element.containing(createElementModel(provider, providerDsl, providerConfig).build())).orElse(null);
    }).filter(Objects::nonNull).findFirst();
    return element;
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) ExtensionMetadataTypeUtils.getId(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getId) RECONNECT_FOREVER_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECT_FOREVER_ELEMENT_IDENTIFIER) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) Optional.of(java.util.Optional.of) TLS_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TLS_PARAMETER_NAME) FlattenedTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.FlattenedTypeAnnotation) ComposableModel(org.mule.runtime.api.meta.model.ComposableModel) EXPIRATION_POLICY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.EXPIRATION_POLICY_ELEMENT_IDENTIFIER) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) REDELIVERY_POLICY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.REDELIVERY_POLICY_ELEMENT_IDENTIFIER) ArrayType(org.mule.metadata.api.model.ArrayType) KEY_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.KEY_ATTRIBUTE_NAME) Map(java.util.Map) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) 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) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) REDELIVERY_POLICY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.REDELIVERY_POLICY_PARAMETER_NAME) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) DslElementModelFactory(org.mule.runtime.config.api.dsl.model.DslElementModelFactory) MetadataTypeUtils.getLocalPart(org.mule.metadata.api.utils.MetadataTypeUtils.getLocalPart) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) ExtensionModelUtils.isContent(org.mule.runtime.extension.api.util.ExtensionModelUtils.isContent) RECONNECT_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECT_ELEMENT_IDENTIFIER) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) SCHEDULING_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.SCHEDULING_STRATEGY_PARAMETER_NAME) ObjectType(org.mule.metadata.api.model.ObjectType) RECONNECTION_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.RECONNECTION_STRATEGY_PARAMETER_NAME) Set(java.util.Set) ExtensionModelUtils.isText(org.mule.runtime.extension.api.util.ExtensionModelUtils.isText) InternalComponentConfiguration(org.mule.runtime.dsl.internal.component.config.InternalComponentConfiguration) POOLING_PROFILE_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.POOLING_PROFILE_PARAMETER_NAME) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) Objects(java.util.Objects) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) NON_REPEATABLE_BYTE_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.NON_REPEATABLE_BYTE_STREAM_ALIAS) HasOperationModels(org.mule.runtime.api.meta.model.operation.HasOperationModels) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) REPEATABLE_FILE_STORE_OBJECTS_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_FILE_STORE_OBJECTS_STREAM_ALIAS) 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) Optional(java.util.Optional) EE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.EE_PREFIX) ComponentIdentifier.builder(org.mule.runtime.api.component.ComponentIdentifier.builder) NON_REPEATABLE_OBJECTS_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.NON_REPEATABLE_OBJECTS_STREAM_ALIAS) ExtensionModelUtils.isRequired(org.mule.runtime.extension.api.util.ExtensionModelUtils.isRequired) Optional.empty(java.util.Optional.empty) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) CronScheduler(org.mule.runtime.core.api.source.scheduler.CronScheduler) CRON_STRATEGY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.CRON_STRATEGY_ELEMENT_IDENTIFIER) REPEATABLE_IN_MEMORY_OBJECTS_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_IN_MEMORY_OBJECTS_STREAM_ALIAS) HasConstructModels(org.mule.runtime.api.meta.model.construct.HasConstructModels) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) REPEATABLE_FILE_STORE_BYTES_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_FILE_STORE_BYTES_STREAM_ALIAS) VALUE_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.VALUE_ATTRIBUTE_NAME) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) Multimap(com.google.common.collect.Multimap) Deque(java.util.Deque) EXPIRATION_POLICY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.EXPIRATION_POLICY_PARAMETER_NAME) ExtensionModelUtils.getDefaultValue(org.mule.runtime.extension.api.util.ExtensionModelUtils.getDefaultValue) Stream.concat(java.util.stream.Stream.concat) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) Iterator(java.util.Iterator) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) RECONNECTION_CONFIG_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.RECONNECTION_CONFIG_PARAMETER_NAME) FixedFrequencyScheduler(org.mule.runtime.core.api.source.scheduler.FixedFrequencyScheduler) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) DslElementModel(org.mule.runtime.config.api.dsl.model.DslElementModel) Collectors.toList(java.util.stream.Collectors.toList) STREAMING_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.STREAMING_STRATEGY_PARAMETER_NAME) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) Reference(org.mule.runtime.api.util.Reference) SCHEDULING_STRATEGY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.SCHEDULING_STRATEGY_ELEMENT_IDENTIFIER) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) ArrayDeque(java.util.ArrayDeque) HasSourceModels(org.mule.runtime.api.meta.model.source.HasSourceModels) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier)

Example 18 with ComponentIdentifier

use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.

the class ConfigurationBasedElementModelFactory method addElementParameter.

private void addElementParameter(Multimap<ComponentIdentifier, ComponentConfiguration> innerComponents, Map<String, String> parameters, DslElementSyntax groupDsl, DslElementModel.Builder<ParameterGroupModel> groupElementBuilder, ParameterModel paramModel) {
    groupDsl.getContainedElement(paramModel.getName()).ifPresent(paramDsl -> {
        if (isInfrastructure(paramModel)) {
            handleInfrastructure(paramModel, paramDsl, innerComponents, parameters, groupElementBuilder);
            return;
        }
        ComponentConfiguration paramComponent = getSingleComponentConfiguration(innerComponents, getIdentifier(paramDsl));
        if (paramDsl.isWrapped()) {
            resolveWrappedElement(groupElementBuilder, paramModel, paramDsl, paramComponent);
            return;
        }
        String value = paramDsl.supportsAttributeDeclaration() ? parameters.get(paramDsl.getAttributeName()) : null;
        Optional<String> defaultValue = getDefaultValue(paramModel);
        if (paramComponent != null || !isBlank(value) || defaultValue.isPresent()) {
            DslElementModel.Builder<ParameterModel> paramElementBuilder = DslElementModel.<ParameterModel>builder().withModel(paramModel).withDsl(paramDsl);
            if (paramComponent != null && !isContent(paramModel)) {
                paramElementBuilder.withConfig(paramComponent);
                paramModel.getType().accept(new MetadataTypeVisitor() {

                    @Override
                    public void visitArrayType(ArrayType arrayType) {
                        MetadataType itemType = arrayType.getType();
                        paramDsl.getGeneric(itemType).ifPresent(itemdsl -> {
                            ComponentIdentifier itemIdentifier = getIdentifier(itemdsl).get();
                            paramComponent.getNestedComponents().forEach(c -> {
                                if (c.getIdentifier().equals(itemIdentifier)) {
                                    itemType.accept(getComponentChildVisitor(paramElementBuilder, c, itemType, VALUE_ATTRIBUTE_NAME, itemdsl, defaultValue, new ArrayDeque<>()));
                                }
                            });
                        });
                    }

                    @Override
                    public void visitObject(ObjectType objectType) {
                        if (isMap(objectType)) {
                            populateMapEntries(objectType, paramDsl, paramElementBuilder, paramComponent);
                            return;
                        }
                        populateObjectFields(objectType, paramComponent, paramDsl, paramElementBuilder, new ArrayDeque<>());
                    }
                });
            } else {
                if (isBlank(value)) {
                    if (paramComponent != null && paramComponent.getValue().isPresent() && !isBlank(paramComponent.getValue().get())) {
                        value = paramComponent.getValue().get().trim();
                    } else if (defaultValue.isPresent()) {
                        value = defaultValue.get();
                        paramElementBuilder.isExplicitInDsl(false);
                    }
                }
                paramElementBuilder.withValue(value);
            }
            groupElementBuilder.containing(paramElementBuilder.build());
        }
    });
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) ExtensionMetadataTypeUtils.getId(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getId) RECONNECT_FOREVER_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECT_FOREVER_ELEMENT_IDENTIFIER) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) Optional.of(java.util.Optional.of) TLS_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TLS_PARAMETER_NAME) FlattenedTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.FlattenedTypeAnnotation) ComposableModel(org.mule.runtime.api.meta.model.ComposableModel) EXPIRATION_POLICY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.EXPIRATION_POLICY_ELEMENT_IDENTIFIER) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) REDELIVERY_POLICY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.REDELIVERY_POLICY_ELEMENT_IDENTIFIER) ArrayType(org.mule.metadata.api.model.ArrayType) KEY_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.KEY_ATTRIBUTE_NAME) Map(java.util.Map) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) 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) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) REDELIVERY_POLICY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.REDELIVERY_POLICY_PARAMETER_NAME) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) DslElementModelFactory(org.mule.runtime.config.api.dsl.model.DslElementModelFactory) MetadataTypeUtils.getLocalPart(org.mule.metadata.api.utils.MetadataTypeUtils.getLocalPart) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) ExtensionModelUtils.isContent(org.mule.runtime.extension.api.util.ExtensionModelUtils.isContent) RECONNECT_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.RECONNECT_ELEMENT_IDENTIFIER) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) SCHEDULING_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.SCHEDULING_STRATEGY_PARAMETER_NAME) ObjectType(org.mule.metadata.api.model.ObjectType) RECONNECTION_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.RECONNECTION_STRATEGY_PARAMETER_NAME) Set(java.util.Set) ExtensionModelUtils.isText(org.mule.runtime.extension.api.util.ExtensionModelUtils.isText) InternalComponentConfiguration(org.mule.runtime.dsl.internal.component.config.InternalComponentConfiguration) POOLING_PROFILE_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.POOLING_PROFILE_PARAMETER_NAME) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) Objects(java.util.Objects) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) NON_REPEATABLE_BYTE_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.NON_REPEATABLE_BYTE_STREAM_ALIAS) HasOperationModels(org.mule.runtime.api.meta.model.operation.HasOperationModels) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) REPEATABLE_FILE_STORE_OBJECTS_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_FILE_STORE_OBJECTS_STREAM_ALIAS) 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) Optional(java.util.Optional) EE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.EE_PREFIX) ComponentIdentifier.builder(org.mule.runtime.api.component.ComponentIdentifier.builder) NON_REPEATABLE_OBJECTS_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.NON_REPEATABLE_OBJECTS_STREAM_ALIAS) ExtensionModelUtils.isRequired(org.mule.runtime.extension.api.util.ExtensionModelUtils.isRequired) Optional.empty(java.util.Optional.empty) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) CronScheduler(org.mule.runtime.core.api.source.scheduler.CronScheduler) CRON_STRATEGY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.CRON_STRATEGY_ELEMENT_IDENTIFIER) REPEATABLE_IN_MEMORY_OBJECTS_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_IN_MEMORY_OBJECTS_STREAM_ALIAS) HasConstructModels(org.mule.runtime.api.meta.model.construct.HasConstructModels) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) REPEATABLE_FILE_STORE_BYTES_STREAM_ALIAS(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder.REPEATABLE_FILE_STORE_BYTES_STREAM_ALIAS) VALUE_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.VALUE_ATTRIBUTE_NAME) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) Multimap(com.google.common.collect.Multimap) Deque(java.util.Deque) EXPIRATION_POLICY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.EXPIRATION_POLICY_PARAMETER_NAME) ExtensionModelUtils.getDefaultValue(org.mule.runtime.extension.api.util.ExtensionModelUtils.getDefaultValue) Stream.concat(java.util.stream.Stream.concat) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) Iterator(java.util.Iterator) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) RECONNECTION_CONFIG_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.RECONNECTION_CONFIG_PARAMETER_NAME) FixedFrequencyScheduler(org.mule.runtime.core.api.source.scheduler.FixedFrequencyScheduler) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) DslElementModel(org.mule.runtime.config.api.dsl.model.DslElementModel) Collectors.toList(java.util.stream.Collectors.toList) STREAMING_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.STREAMING_STRATEGY_PARAMETER_NAME) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) Reference(org.mule.runtime.api.util.Reference) SCHEDULING_STRATEGY_ELEMENT_IDENTIFIER(org.mule.runtime.internal.dsl.DslConstants.SCHEDULING_STRATEGY_ELEMENT_IDENTIFIER) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) ArrayDeque(java.util.ArrayDeque) HasSourceModels(org.mule.runtime.api.meta.model.source.HasSourceModels) MetadataType(org.mule.metadata.api.model.MetadataType) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ArrayDeque(java.util.ArrayDeque) InternalComponentConfiguration(org.mule.runtime.dsl.internal.component.config.InternalComponentConfiguration) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) ArrayType(org.mule.metadata.api.model.ArrayType) ObjectType(org.mule.metadata.api.model.ObjectType) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) DslElementModel(org.mule.runtime.config.api.dsl.model.DslElementModel)

Example 19 with ComponentIdentifier

use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.

the class SecureConfigurationPropertiesProviderFactory method createProvider.

@Override
public SecureConfigurationPropertiesProvider createProvider(ConfigurationParameters parameters, ResourceProvider externalResourceProvider) {
    String file = parameters.getStringParameter("file");
    Preconditions.checkArgument(file != null, "Required attribute 'file' of 'secure-configuration-properties' not found");
    ComponentIdentifier encryptComponentIdentifier = ComponentIdentifier.builder().namespace(EXTENSION_NAME).name("encrypt").build();
    String algorithm = parameters.getComplexConfigurationParameter(encryptComponentIdentifier).get(0).getStringParameter("algorithm");
    String mode = parameters.getComplexConfigurationParameter(encryptComponentIdentifier).get(0).getStringParameter("mode");
    return new SecureConfigurationPropertiesProvider(externalResourceProvider, file, algorithm, mode);
}
Also used : ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier)

Example 20 with ComponentIdentifier

use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.

the class ExtensionErrorsRegistrant method getErrorType.

private ErrorType getErrorType(ErrorModel errorModel, ExtensionModel extensionModel) {
    ComponentIdentifier identifier = createIdentifier(errorModel.getType(), errorModel.getNamespace());
    Optional<ErrorType> optionalError = errorTypeRepository.getErrorType(identifier);
    return optionalError.orElseGet(() -> createErrorType(errorModel, identifier, extensionModel));
}
Also used : ErrorType(org.mule.runtime.api.message.ErrorType) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier)

Aggregations

ComponentIdentifier (org.mule.runtime.api.component.ComponentIdentifier)20 Map (java.util.Map)10 Optional (java.util.Optional)9 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)9 Optional.of (java.util.Optional.of)8 List (java.util.List)7 Optional.empty (java.util.Optional.empty)7 Set (java.util.Set)7 ComponentConfiguration (org.mule.runtime.dsl.api.component.config.ComponentConfiguration)7 String.format (java.lang.String.format)6 MetadataType (org.mule.metadata.api.model.MetadataType)6 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)6 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)6 DslElementModel (org.mule.runtime.config.api.dsl.model.DslElementModel)6 InternalComponentConfiguration (org.mule.runtime.dsl.internal.component.config.InternalComponentConfiguration)6 HashMap (java.util.HashMap)5 StringUtils.isBlank (org.apache.commons.lang3.StringUtils.isBlank)5 ComponentIdentifier.builder (org.mule.runtime.api.component.ComponentIdentifier.builder)5 Collectors.toList (java.util.stream.Collectors.toList)4 StringUtils.isNotBlank (org.apache.commons.lang3.StringUtils.isNotBlank)4