Search in sources :

Example 1 with ConnectionProviderResolver

use of org.mule.runtime.module.extension.internal.runtime.resolver.ConnectionProviderResolver 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)

Example 2 with ConnectionProviderResolver

use of org.mule.runtime.module.extension.internal.runtime.resolver.ConnectionProviderResolver in project mule by mulesoft.

the class ConnectionProviderObjectFactory method doGetObject.

@Override
public ConnectionProviderResolver doGetObject() throws Exception {
    Callable<ResolverSet> callable = () -> getParametersResolver().getParametersAsHashedResolverSet(providerModel, muleContext);
    ResolverSet resolverSet = withContextClassLoader(getClassLoader(extensionModel), callable);
    ConnectionProviderObjectBuilder builder;
    if (extensionModel.getModelProperty(SoapExtensionModelProperty.class).isPresent()) {
        builder = new SoapConnectionProviderObjectBuilder(providerModel, resolverSet, poolingProfile, reconnectionConfig, extensionModel, muleContext);
    } else if (providerModel.getModelProperty(OAuthModelProperty.class).isPresent()) {
        builder = new OAuthConnectionProviderObjectBuilder(providerModel, resolverSet, poolingProfile, reconnectionConfig, oauthManager, extensionModel, muleContext);
    } else {
        builder = new DefaultConnectionProviderObjectBuilder(providerModel, resolverSet, poolingProfile, reconnectionConfig, extensionModel, muleContext);
    }
    return new ConnectionProviderResolver<>(builder, resolverSet, muleContext);
}
Also used : ResolverSet(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet) SoapConnectionProviderObjectBuilder(org.mule.runtime.module.extension.soap.internal.runtime.connection.SoapConnectionProviderObjectBuilder) DefaultConnectionProviderObjectBuilder(org.mule.runtime.module.extension.internal.runtime.config.DefaultConnectionProviderObjectBuilder) OAuthConnectionProviderObjectBuilder(org.mule.runtime.module.extension.internal.runtime.connectivity.oauth.OAuthConnectionProviderObjectBuilder) ConnectionProviderObjectBuilder(org.mule.runtime.module.extension.internal.runtime.config.ConnectionProviderObjectBuilder) SoapConnectionProviderObjectBuilder(org.mule.runtime.module.extension.soap.internal.runtime.connection.SoapConnectionProviderObjectBuilder) OAuthConnectionProviderObjectBuilder(org.mule.runtime.module.extension.internal.runtime.connectivity.oauth.OAuthConnectionProviderObjectBuilder) ConnectionProviderResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ConnectionProviderResolver) SoapExtensionModelProperty(org.mule.runtime.module.extension.soap.internal.loader.property.SoapExtensionModelProperty) DefaultConnectionProviderObjectBuilder(org.mule.runtime.module.extension.internal.runtime.config.DefaultConnectionProviderObjectBuilder)

Aggregations

ConnectionProviderResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ConnectionProviderResolver)2 ResolverSet (org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet)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 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)1 MuleContext (org.mule.runtime.core.api.MuleContext)1 ConfigurationException (org.mule.runtime.core.api.config.ConfigurationException)1 LifecycleUtils.initialiseIfNeeded (org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded)1 ClassUtils.withContextClassLoader (org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader)1 CheckedConsumer (org.mule.runtime.core.api.util.func.CheckedConsumer)1 ObjectFactory (org.mule.runtime.dsl.api.component.ObjectFactory)1 ClassLoaderModelProperty (org.mule.runtime.extension.api.property.ClassLoaderModelProperty)1 ExpirationPolicy (org.mule.runtime.extension.api.runtime.ExpirationPolicy)1 ConfigurationProvider (org.mule.runtime.extension.api.runtime.config.ConfigurationProvider)1