use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class ExtensionComponent method getMetadataContext.
private MetadataContext getMetadataContext() throws MetadataResolvingException {
CoreEvent fakeEvent = null;
try {
fakeEvent = getInitialiserEvent(muleContext);
Optional<ConfigurationInstance> configuration = getConfiguration(fakeEvent);
if (configuration.isPresent()) {
ConfigurationProvider configurationProvider = findConfigurationProvider().orElseThrow(() -> new MetadataResolvingException("Failed to create the required configuration for Metadata retrieval", INVALID_CONFIGURATION));
if (configurationProvider instanceof DynamicConfigurationProvider) {
throw new MetadataResolvingException("Configuration used for Metadata fetch cannot be dynamic", INVALID_CONFIGURATION);
}
}
String cacheId = configuration.map(ConfigurationInstance::getName).orElseGet(() -> extensionModel.getName() + "|" + componentModel.getName());
return new DefaultMetadataContext(() -> configuration, connectionManager, metadataService.getMetadataCache(cacheId), typeLoader);
} finally {
if (fakeEvent != null) {
((BaseEventContext) fakeEvent.getContext()).success();
}
}
}
use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class DefaultConfigurationProviderFactory method createStaticConfigurationProvider.
/**
* {@inheritDoc}
*/
@Override
public ConfigurationProvider createStaticConfigurationProvider(String name, ExtensionModel extensionModel, ConfigurationModel configurationModel, ResolverSet resolverSet, ConnectionProviderValueResolver connectionProviderResolver, ReflectionCache reflectionCache, MuleContext muleContext) throws Exception {
return withExtensionClassLoader(extensionModel, () -> {
configureConnectionProviderResolver(name, connectionProviderResolver);
ConfigurationInstance configuration;
CoreEvent initialiserEvent = null;
try {
initialiserEvent = getInitialiserEvent(muleContext);
initialiseIfNeeded(resolverSet, true, muleContext);
configuration = new ConfigurationInstanceFactory(extensionModel, configurationModel, resolverSet, reflectionCache, muleContext).createConfiguration(name, initialiserEvent, connectionProviderResolver);
} catch (MuleException e) {
throw new ConfigurationException(createStaticMessage(format("Could not create configuration '%s' for the '%s'", name, extensionModel.getName())), e);
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
}
}
return new ConfigurationProviderToolingAdapter(name, extensionModel, configurationModel, configuration, reflectionCache, muleContext);
});
}
use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class OAuthConnectionProviderObjectBuilder method getInitialOAuthConfig.
private OAuthConfig getInitialOAuthConfig() throws MuleException {
CoreEvent initialiserEvent = null;
try {
initialiserEvent = getInitialiserEvent(muleContext);
MapValueResolver mapResolver = staticOnly((MapValueResolver) resolverSet.getResolvers().get(OAUTH_AUTHORIZATION_CODE_GROUP_NAME));
AuthCodeConfig authCodeConfig = buildAuthCodeConfig(mapResolver.resolve(from(initialiserEvent)));
Optional<OAuthObjectStoreConfig> storeConfig = buildOAuthObjectStoreConfig(initialiserEvent);
mapResolver = staticOnly((MapValueResolver) resolverSet.getResolvers().get(OAUTH_CALLBACK_GROUP_NAME));
OAuthCallbackConfig callbackConfig = buildOAuthCallbackConfig(mapResolver.resolve(from(initialiserEvent)));
return new OAuthConfig(ownerConfigName, authCodeConfig, callbackConfig, storeConfig, grantType, getCustomParameters(initialiserEvent), callbackValues);
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
}
}
}
use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class ReflectiveOperationExecutorFactory method createExecutor.
@Override
public ComponentExecutor<M> createExecutor(M operationModel, Map<String, Object> parameters) {
DefaultObjectBuilder objectBuilder = new DefaultObjectBuilder(implementationClass);
parameters.forEach((k, v) -> objectBuilder.addPropertyResolver(k, new StaticValueResolver<>(v)));
Object delegate;
CoreEvent initialiserEvent = null;
try {
initialiserEvent = getInitialiserEvent();
delegate = objectBuilder.build(from(initialiserEvent));
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage("Could not create instance of operation class " + implementationClass.getName()), e);
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
}
}
return new ReflectiveMethodOperationExecutor(operationModel, operationMethod, delegate);
}
use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class ParameterGroupObjectBuilder method build.
public T build(ResolverSetResult result) throws MuleException {
final Map<String, Object> resultMap = result.asMap();
CoreEvent initialiserEvent = null;
try {
initialiserEvent = getInitialiserEvent();
return doBuild(resultMap::containsKey, resultMap::get, from(initialiserEvent));
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
}
}
}
Aggregations