use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet 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;
});
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet 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);
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet in project mule by mulesoft.
the class ExtensionSourceObjectFactory method doGetObject.
@Override
public ExtensionMessageSource doGetObject() throws ConfigurationException, InitialisationException {
return withContextClassLoader(getClassLoader(extensionModel), () -> {
getParametersResolver().checkParameterGroupExclusiveness(Optional.of(sourceModel), sourceModel.getParameterGroupModels(), parameters.keySet());
ResolverSet nonCallbackParameters = getNonCallbackParameters();
if (nonCallbackParameters.isDynamic()) {
throw dynamicParameterException(nonCallbackParameters, sourceModel);
}
ResolverSet responseCallbackParameters = getCallbackParameters(sourceModel.getSuccessCallback());
ResolverSet errorCallbackParameters = getCallbackParameters(sourceModel.getErrorCallback());
initialiseIfNeeded(nonCallbackParameters, true, muleContext);
initialiseIfNeeded(responseCallbackParameters, true, muleContext);
initialiseIfNeeded(errorCallbackParameters, true, muleContext);
final BackPressureStrategy backPressureStrategy = getBackPressureStrategy();
return new ExtensionMessageSource(extensionModel, sourceModel, getSourceAdapterFactory(nonCallbackParameters, responseCallbackParameters, errorCallbackParameters, backPressureStrategy), configurationProvider, primaryNodeOnly != null ? primaryNodeOnly : sourceModel.runsOnPrimaryNodeOnly(), getRetryPolicyTemplate(), cursorProviderFactory, backPressureStrategy, muleContext.getExtensionManager());
});
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet in project mule by mulesoft.
the class ComponentMessageProcessorBuilder method build.
public P build() {
return withContextClassLoader(getClassLoader(extensionModel), () -> {
try {
final ExtensionManager extensionManager = muleContext.getExtensionManager();
final ResolverSet operationArguments = getArgumentsResolverSet();
P processor = createMessageProcessor(extensionManager, operationArguments);
// TODO: MULE-5002 this should not be necessary but lifecycle issues when injecting message processors automatically
muleContext.getInjector().inject(processor);
return processor;
} catch (Exception e) {
throw new MuleRuntimeException(e);
}
});
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet in project mule by mulesoft.
the class ImplicitObjectUtils method buildImplicitResolverSet.
/**
* Creates a {@link ResolverSet} based on the default values for the {@link ParameterModel}s in the {@code parametrizedModel}.
* <p>
* If a {@link ParameterModel} returns {@code null} for {@link ParameterModel#getDefaultValue()} then it's ignored
*
* @param model a model holding the {@link ParameterModel}s to consider
* @param muleContext the Mule node.
* @return a {@link ResolverSet}
*/
public static ResolverSet buildImplicitResolverSet(ParameterizedModel model, ReflectionCache reflectionCache, MuleContext muleContext) {
ResolverSet resolverSet = new HashedResolverSet(muleContext);
ParametersResolver parametersResolver = ParametersResolver.fromDefaultValues(model, muleContext, reflectionCache);
for (ParameterGroupModel groupModel : model.getParameterGroupModels()) {
Optional<ParameterGroupDescriptor> descriptor = groupModel.getModelProperty(ParameterGroupModelProperty.class).map(ParameterGroupModelProperty::getDescriptor);
if (descriptor.isPresent() && groupModel.getParameterModels().stream().noneMatch(ParameterModel::isRequired)) {
String groupKey = getContainerName(descriptor.get().getContainer());
resolverSet.add(groupKey, NullSafeValueResolverWrapper.of(new StaticValueResolver<>(null), descriptor.get().getMetadataType(), reflectionCache, muleContext, parametersResolver));
} else {
groupModel.getParameterModels().forEach(parameterModel -> {
Object defaultValue = parameterModel.getDefaultValue();
ValueResolver<?> resolver;
if (defaultValue instanceof String) {
resolver = getExpressionBasedValueResolver((String) defaultValue, parameterModel.getType(), muleContext);
} else {
resolver = new StaticValueResolver<>(null);
}
if (parameterModel.getModelProperty(NullSafeModelProperty.class).isPresent()) {
MetadataType metadataType = parameterModel.getModelProperty(NullSafeModelProperty.class).get().defaultType();
resolver = NullSafeValueResolverWrapper.of(resolver, metadataType, reflectionCache, muleContext, parametersResolver);
}
resolverSet.add(parameterModel.getName(), resolver);
});
}
}
return resolverSet;
}
Aggregations