Search in sources :

Example 11 with ConfigurationProvider

use of org.mule.runtime.extension.api.runtime.config.ConfigurationProvider in project mule by mulesoft.

the class ConfigurationProviderObjectFactory method createInnerInstance.

private ConfigurationProvider createInnerInstance() throws ConfigurationException {
    if (expirationPolicy == null) {
        expirationPolicy = muleContext.getConfiguration().getDynamicConfigExpiration().getExpirationPolicy();
    }
    ResolverSet resolverSet = getParametersResolver().getParametersAsHashedResolverSet(configurationModel, muleContext);
    final ConnectionProviderValueResolver connectionProviderResolver = getConnectionProviderResolver();
    return withContextClassLoader(getExtensionClassLoader(), () -> {
        connectionProviderResolver.getResolverSet().ifPresent((CheckedConsumer) resolver -> initialiseIfNeeded(resolver, true, muleContext));
        ConfigurationProvider configurationProvider;
        try {
            if (resolverSet.isDynamic() || connectionProviderResolver.isDynamic()) {
                configurationProvider = configurationProviderFactory.createDynamicConfigurationProvider(name, extensionModel, configurationModel, resolverSet, connectionProviderResolver, expirationPolicy, reflectionCache, muleContext);
            } else {
                configurationProvider = configurationProviderFactory.createStaticConfigurationProvider(name, extensionModel, configurationModel, resolverSet, connectionProviderResolver, reflectionCache, muleContext);
            }
        } catch (Exception e) {
            throw new MuleRuntimeException(createStaticMessage(format("Could not create an implicit configuration '%s' for the extension '%s'", configurationModel.getName(), extensionModel.getName())), e);
        }
        return configurationProvider;
    });
}
Also used : ResolverSet(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet) Optional.empty(java.util.Optional.empty) Thread.currentThread(java.lang.Thread.currentThread) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) ConnectionProviderValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ConnectionProviderValueResolver) ResolverSet(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet) ExpirationPolicy(org.mule.runtime.extension.api.runtime.ExpirationPolicy) MuleContext(org.mule.runtime.core.api.MuleContext) DefaultConfigurationProviderFactory(org.mule.runtime.module.extension.internal.runtime.config.DefaultConfigurationProviderFactory) ClassUtils.withContextClassLoader(org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader) ObjectFactory(org.mule.runtime.dsl.api.component.ObjectFactory) CheckedConsumer(org.mule.runtime.core.api.util.func.CheckedConsumer) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) ConfigurationProvider(org.mule.runtime.extension.api.runtime.config.ConfigurationProvider) Optional.ofNullable(java.util.Optional.ofNullable) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) ImplicitConnectionProviderValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ImplicitConnectionProviderValueResolver) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ClassLoaderModelProperty(org.mule.runtime.extension.api.property.ClassLoaderModelProperty) StaticConnectionProviderResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticConnectionProviderResolver) String.format(java.lang.String.format) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ConnectionProviderResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ConnectionProviderResolver) AbstractExtensionObjectFactory(org.mule.runtime.module.extension.internal.config.dsl.AbstractExtensionObjectFactory) ConfigurationProviderFactory(org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderFactory) Optional(java.util.Optional) ConfigurationProvider(org.mule.runtime.extension.api.runtime.config.ConfigurationProvider) ConnectionProviderValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ConnectionProviderValueResolver) ImplicitConnectionProviderValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ImplicitConnectionProviderValueResolver) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException)

Aggregations

ConfigurationProvider (org.mule.runtime.extension.api.runtime.config.ConfigurationProvider)11 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)10 Test (org.junit.Test)8 SmallTest (org.mule.tck.size.SmallTest)8 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)5 ConfigurationInstance (org.mule.runtime.extension.api.runtime.config.ConfigurationInstance)5 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)2 String.format (java.lang.String.format)1 Thread.currentThread (java.lang.Thread.currentThread)1 Optional (java.util.Optional)1 Optional.empty (java.util.Optional.empty)1 Optional.ofNullable (java.util.Optional.ofNullable)1 ExecutionException (java.util.concurrent.ExecutionException)1 MuleException (org.mule.runtime.api.exception.MuleException)1 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)1 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)1 MetadataResolvingException (org.mule.runtime.api.metadata.MetadataResolvingException)1 MuleContext (org.mule.runtime.core.api.MuleContext)1