Search in sources :

Example 31 with ConfigurationModel

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

the class MacroExpansionModuleModel method getModuleGlobalElements.

private List<ComponentModel> getModuleGlobalElements() {
    List<ComponentModel> moduleGlobalElements = new ArrayList<>();
    Optional<ConfigurationModel> config = getConfigurationModel();
    if (config.isPresent() && config.get().getModelProperty(GlobalElementComponentModelModelProperty.class).isPresent()) {
        GlobalElementComponentModelModelProperty globalElementComponentModelModelProperty = config.get().getModelProperty(GlobalElementComponentModelModelProperty.class).get();
        moduleGlobalElements = globalElementComponentModelModelProperty.getGlobalElements();
    }
    return moduleGlobalElements;
}
Also used : ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) GlobalElementComponentModelModelProperty(org.mule.runtime.config.internal.dsl.model.extension.xml.property.GlobalElementComponentModelModelProperty) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) ArrayList(java.util.ArrayList)

Example 32 with ConfigurationModel

use of org.mule.runtime.api.meta.model.config.ConfigurationModel 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 33 with ConfigurationModel

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

the class DeclarationBasedElementModelFactory method createConfigurationElement.

private DslElementModel<ConfigurationModel> createConfigurationElement(ConfigurationModel model, ConfigurationElementDeclaration configDeclaration) {
    DslElementSyntax configDsl = dsl.resolve(model);
    InternalComponentConfiguration.Builder configuration = InternalComponentConfiguration.builder().withIdentifier(asIdentifier(configDsl)).withParameter(NAME_ATTRIBUTE_NAME, configDeclaration.getRefName());
    DslElementModel.Builder<ConfigurationModel> element = createParameterizedElementModel(model, configDsl, configDeclaration, configuration);
    configDeclaration.getConnection().ifPresent(connection -> addConnectionProvider(connection, model, configuration, element));
    return element.withConfig(configuration.build()).build();
}
Also used : ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) DslElementModel(org.mule.runtime.config.api.dsl.model.DslElementModel) InternalComponentConfiguration(org.mule.runtime.dsl.internal.component.config.InternalComponentConfiguration)

Example 34 with ConfigurationModel

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

the class DefaultExtensionManager method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
public Optional<ConfigurationInstance> getConfiguration(ExtensionModel extensionModel, ComponentModel componentModel, CoreEvent muleEvent) {
    ConfigurationInstance instance = getConfigurationProvider(extensionModel, componentModel).map(p -> p.get(muleEvent)).orElse(null);
    if (instance != null) {
        return of(instance);
    }
    Optional<ConfigurationModel> configurationModel = getConfigurationModelForExtension(extensionModel, getConfigurationForComponent(extensionModel, componentModel));
    if (configurationModel.isPresent()) {
        createImplicitConfiguration(extensionModel, configurationModel.get(), muleEvent);
        return of(getConfiguration(getImplicitConfigurationProviderName(extensionModel, configurationModel.get()), muleEvent));
    }
    return empty();
}
Also used : Optional.empty(java.util.Optional.empty) Optional.of(java.util.Optional.of) MuleExtensionUtils.getClassLoader(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.getClassLoader) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) LoggerFactory(org.slf4j.LoggerFactory) ExtensionModelUtils.getConfigurationForComponent(org.mule.runtime.extension.api.util.ExtensionModelUtils.getConfigurationForComponent) Preconditions.checkArgument(org.mule.runtime.api.util.Preconditions.checkArgument) MuleContextAware(org.mule.runtime.core.api.context.MuleContextAware) DefaultRegistry(org.mule.runtime.core.internal.registry.DefaultRegistry) Inject(javax.inject.Inject) MuleContext(org.mule.runtime.core.api.MuleContext) DefaultImplicitConfigurationProviderFactory(org.mule.runtime.module.extension.internal.runtime.config.DefaultImplicitConfigurationProviderFactory) MuleException(org.mule.runtime.api.exception.MuleException) LifecycleUtils.stopIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.stopIfNeeded) Registry(org.mule.runtime.api.artifact.Registry) ClassUtils.withContextClassLoader(org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader) Builder.newBuilder(org.mule.runtime.module.extension.internal.manager.DefaultConfigurationExpirationMonitor.Builder.newBuilder) Time(org.mule.runtime.api.time.Time) StringUtils(org.mule.runtime.core.api.util.StringUtils) PrivilegedMuleContext(org.mule.runtime.core.privileged.PrivilegedMuleContext) Startable(org.mule.runtime.api.lifecycle.Startable) ImplicitConfigurationProviderFactory(org.mule.runtime.module.extension.internal.runtime.config.ImplicitConfigurationProviderFactory) Logger(org.slf4j.Logger) ConfigurationProvider(org.mule.runtime.extension.api.runtime.config.ConfigurationProvider) Optional.ofNullable(java.util.Optional.ofNullable) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Set(java.util.Set) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ConfigurationInstance(org.mule.runtime.extension.api.runtime.config.ConfigurationInstance) Initialisable(org.mule.runtime.api.lifecycle.Initialisable) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) ExtensionModelUtils.requiresConfig(org.mule.runtime.extension.api.util.ExtensionModelUtils.requiresConfig) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ExtensionModelUtils(org.mule.runtime.extension.api.util.ExtensionModelUtils) LifecycleUtils.disposeIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.disposeIfNeeded) List(java.util.List) ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) Stoppable(org.mule.runtime.api.lifecycle.Stoppable) Optional(java.util.Optional) MuleExtensionUtils.getImplicitConfigurationProviderName(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.getImplicitConfigurationProviderName) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ConfigurationInstance(org.mule.runtime.extension.api.runtime.config.ConfigurationInstance)

Example 35 with ConfigurationModel

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

the class NameClashModelValidatorTestCase method differentNamesClashWhenHyphenized.

@Test
public void differentNamesClashWhenHyphenized() {
    exception.expect(IllegalModelDefinitionException.class);
    exception.expectMessage("contains 2 components 'config-name");
    ConfigurationModel configuration = mock(ConfigurationModel.class);
    mockModelProperties(configuration);
    when(configuration.getName()).thenReturn("config-name");
    when(configurationModel.getName()).thenReturn("ConfigName");
    when(configuration.getAllParameterModels()).thenReturn(asList(simpleConfigParam, topLevelConfigParam));
    when(configuration.getOperationModels()).thenReturn(ImmutableList.of());
    when(configuration.getConnectionProviders()).thenReturn(ImmutableList.of());
    when(extensionModel.getConfigurationModels()).thenReturn(asList(configurationModel, configuration));
    validate();
}
Also used : ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)35 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)19 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)16 Test (org.junit.Test)15 ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)13 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)11 Optional (java.util.Optional)9 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)9 List (java.util.List)8 Set (java.util.Set)7 ObjectType (org.mule.metadata.api.model.ObjectType)7 ConstructModel (org.mule.runtime.api.meta.model.construct.ConstructModel)7 HasOperationModels (org.mule.runtime.api.meta.model.operation.HasOperationModels)7 ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)7 ExtensionWalker (org.mule.runtime.api.meta.model.util.ExtensionWalker)7 DslElementSyntax (org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)7 DslSyntaxResolver (org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 MetadataType (org.mule.metadata.api.model.MetadataType)6