use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.
the class DynamicConfigurationProvider method get.
/**
* Evaluates {@link #resolverSet} using the given {@code event} and returns an instance produced with the result. For equivalent
* {@link ResolverSetResult}s it will return the same instance.
*
* @param event the current {@code event}
* @return the resolved {@link ConfigurationInstance}
*/
@Override
public ConfigurationInstance get(Event event) {
return withContextClassLoader(getExtensionClassLoader(), () -> {
ResolverSetResult result = resolverSet.resolve(from((CoreEvent) event));
ResolverSetResult providerResult = null;
if (connectionProviderResolver.getResolverSet().isPresent()) {
providerResult = ((ResolverSet) connectionProviderResolver.getResolverSet().get()).resolve(from((CoreEvent) event));
}
return getConfiguration(new Pair<>(result, providerResult), (CoreEvent) event);
});
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.
the class OAuthConnectionProviderObjectBuilder method build.
@Override
public Pair<ConnectionProvider<C>, ResolverSetResult> build(ValueResolvingContext context) throws MuleException {
ResolverSetResult result = resolverSet.resolve(context);
ConnectionProvider<C> provider = super.doBuild(result);
OAuthConfig config = new OAuthConfig(ownerConfigName, buildAuthCodeConfig(context.getEvent()), buildOAuthCallbackConfig(context.getEvent()), buildOAuthObjectStoreConfig(context.getEvent()), grantType, getCustomParameters(result), getCallbackValues());
provider = new OAuthConnectionProviderWrapper<>(provider, config, getCallbackValues(), oauthManager, reconnectionConfig);
return new Pair<>(provider, result);
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.
the class DynamicConfigurationProvider method createConfiguration.
private ConfigurationInstance createConfiguration(Pair<ResolverSetResult, ResolverSetResult> values, CoreEvent event) throws MuleException {
ConfigurationInstance configuration;
ResolverSetResult connectionProviderValues = values.getSecond();
if (connectionProviderValues != null) {
configuration = configurationInstanceFactory.createConfiguration(getName(), values.getFirst(), event, connectionProviderResolver, connectionProviderValues);
} else {
configuration = configurationInstanceFactory.createConfiguration(getName(), values.getFirst(), event, ofNullable(connectionProviderResolver));
}
registerConfiguration(configuration);
return configuration;
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.
the class ConfigurationInstanceFactoryTestCase method createFromResolverSetResult.
@Test
public void createFromResolverSetResult() throws Exception {
ResolverSetResult result = ResolverSetResult.newBuilder().build();
ConfigurationInstance configurationInstance = factory.createConfiguration(CONFIG_NAME, result, event, empty());
assertConfiguration(configurationInstance);
assertThat(configurationInstance.getConnectionProvider().isPresent(), is(false));
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.
the class DynamicConfigurationProviderTestCase method makeAlternateInstance.
private HeisenbergExtension makeAlternateInstance() throws Exception {
ResolverSetResult alternateResult = mock(ResolverSetResult.class, Mockito.RETURNS_DEEP_STUBS);
when(alternateResult.asMap()).thenReturn(new HashMap<>());
mockConfigurationInstance(configurationModel, MODULE_CLASS.newInstance());
when(resolverSet.resolve(from(event))).thenReturn(alternateResult);
return (HeisenbergExtension) provider.get(event).getValue();
}
Aggregations