use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class DefaultExtensionsClient method createProcessor.
/**
* Creates a new {@link OperationMessageProcessor} for the required operation and parses all the parameters passed by the client
* user.
*/
private OperationMessageProcessor createProcessor(String extensionName, String operationName, OperationParameters parameters) {
ExtensionModel extension = findExtension(extensionName);
OperationModel operation = findOperation(extension, operationName);
ConfigurationProvider config = parameters.getConfigName().map(this::findConfiguration).orElse(null);
Map<String, ValueResolver> resolvedParams = resolveParameters(parameters.get(), getEvent());
try {
OperationMessageProcessor processor = new OperationMessageProcessorBuilder(extension, operation, policyManager, muleContext, registry).setConfigurationProvider(config).setParameters(resolvedParams).build();
initialiseIfNeeded(processor, muleContext);
processor.start();
return processor;
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage("Could not create Operation Message Processor"), e);
}
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class DefaultImplicitConfigurationProviderFactory method createImplicitConfigurationProvider.
/**
* {@inheritDoc}
*/
@Override
public ConfigurationProvider createImplicitConfigurationProvider(ExtensionModel extensionModel, ConfigurationModel implicitConfigurationModel, CoreEvent event, ReflectionCache reflectionCache, MuleContext muleContext) {
if (implicitConfigurationModel == null || !canBeUsedImplicitly(implicitConfigurationModel)) {
throw new IllegalStateException("Could not find a config for extension '" + extensionModel.getName() + "' and none can be created automatically. Please define one");
}
final String providerName = getImplicitConfigurationProviderName(extensionModel, implicitConfigurationModel);
Callable<ResolverSet> resolverSetCallable = () -> buildImplicitResolverSet(implicitConfigurationModel, reflectionCache, muleContext);
ClassLoader pluginClassloader = getClassLoader(extensionModel);
final ResolverSet resolverSet = withContextClassLoader(pluginClassloader, resolverSetCallable);
try {
ImplicitConnectionProviderValueResolver implicitConnectionProviderValueResolver = new ImplicitConnectionProviderValueResolver(implicitConfigurationModel.getName(), extensionModel, implicitConfigurationModel, reflectionCache, muleContext);
ConfigurationInstance configurationInstance = withContextClassLoader(pluginClassloader, () -> new ConfigurationInstanceFactory(extensionModel, implicitConfigurationModel, resolverSet, reflectionCache, muleContext).createConfiguration(providerName, event, implicitConnectionProviderValueResolver));
if (resolverSet.isDynamic() || needsDynamicConnectionProvider(extensionModel, implicitConfigurationModel, implicitConnectionProviderValueResolver)) {
return new DynamicConfigurationProvider(providerName, extensionModel, implicitConfigurationModel, resolverSet, implicitConnectionProviderValueResolver, ImmutableExpirationPolicy.getDefault(new LocalTimeSupplier()), reflectionCache, muleContext);
}
return new ConfigurationProviderToolingAdapter(providerName, extensionModel, implicitConfigurationModel, configurationInstance, reflectionCache, muleContext);
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage(format("Could not create an implicit configuration '%s' for the extension '%s'", implicitConfigurationModel.getName(), extensionModel.getName())), e);
}
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class DefaultImplicitConnectionProviderFactory method createImplicitConnectionProvider.
/**
* {@inheritDoc}
*/
@Override
public <T> Pair<ConnectionProvider<T>, ResolverSetResult> createImplicitConnectionProvider(String configName, CoreEvent event) {
ResolverSet resolverSet = resolverSetProvider.get();
ConnectionProviderObjectBuilder<T> builder = new DefaultConnectionProviderObjectBuilder<>(connectionProviderModel, resolverSet, extensionModel, muleContext);
builder.setOwnerConfigName(configName);
try {
return builder.build(from(event));
} catch (MuleException e) {
throw new MuleRuntimeException(e);
}
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class DynamicConfigurationProvider method doInitialise.
@Override
protected void doInitialise() {
try {
initialiseIfNeeded(resolverSet, muleContext);
initialiseIfNeeded(connectionProviderResolver, muleContext);
} catch (InitialisationException e) {
throw new MuleRuntimeException(e);
}
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class ReflectiveMethodComponentExecutor method getMethodArgumentResolver.
private LazyValue<ArgumentResolverDelegate> getMethodArgumentResolver(List<ParameterGroupModel> groups, Method method) {
return new LazyValue<>(() -> {
try {
MethodArgumentResolverDelegate resolver = new MethodArgumentResolverDelegate(groups, method);
initialiseIfNeeded(resolver, muleContext);
return resolver;
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage("Could not initialize argument resolver resolver"), e);
}
});
}
Aggregations