use of org.mule.runtime.dsl.api.component.config.DefaultComponentLocation in project mule by mulesoft.
the class ComponentLocationVisitor method processErrorHandlerComponent.
private DefaultComponentLocation processErrorHandlerComponent(ComponentModel componentModel, DefaultComponentLocation parentComponentLocation, Optional<TypedComponentIdentifier> typedComponentIdentifier) {
DefaultComponentLocation componentLocation;
componentLocation = parentComponentLocation.appendLocationPart("errorHandler", typedComponentIdentifier, componentModel.getConfigFileName(), componentModel.getLineNumber());
return componentLocation;
}
use of org.mule.runtime.dsl.api.component.config.DefaultComponentLocation in project mule by mulesoft.
the class MVELExpressionLanguageTestCase method setupMVEL.
@Before
public void setupMVEL() throws InitialisationException {
mvel = new MVELExpressionLanguage(muleContext);
mvel.initialise();
flowConstruct = mock(FlowConstruct.class, withSettings().extraInterfaces(Component.class));
when(flowConstruct.getName()).thenReturn("myFlow");
final DefaultComponentLocation location = fromSingleComponent("myFlow");
when(((Component) flowConstruct).getAnnotation(LOCATION_KEY)).thenReturn(location);
when(((Component) flowConstruct).getLocation()).thenReturn(location);
}
use of org.mule.runtime.dsl.api.component.config.DefaultComponentLocation in project mule by mulesoft.
the class ApplicationModel method getConfigurationPropertiesProvidersFromComponents.
private List<ConfigurationPropertiesProvider> getConfigurationPropertiesProvidersFromComponents(ArtifactConfig artifactConfig, ConfigurationPropertiesResolver localResolver) {
Map<ComponentIdentifier, ConfigurationPropertiesProviderFactory> providerFactoriesMap = new HashMap<>();
ServiceLoader<ConfigurationPropertiesProviderFactory> providerFactories = java.util.ServiceLoader.load(ConfigurationPropertiesProviderFactory.class);
providerFactories.forEach(service -> {
ComponentIdentifier componentIdentifier = service.getSupportedComponentIdentifier();
if (providerFactoriesMap.containsKey(componentIdentifier)) {
throw new MuleRuntimeException(createStaticMessage("Multiple configuration providers for component: " + componentIdentifier));
}
providerFactoriesMap.put(componentIdentifier, service);
});
List<ConfigurationPropertiesProvider> configConfigurationPropertiesProviders = new ArrayList<>();
artifactConfig.getConfigFiles().stream().forEach(configFile -> configFile.getConfigLines().stream().forEach(configLine -> {
for (ConfigLine componentConfigLine : configLine.getChildren()) {
if (componentConfigLine.getNamespace() == null) {
continue;
}
ComponentIdentifier componentIdentifier = ComponentIdentifier.builder().namespace(componentConfigLine.getNamespace()).name(componentConfigLine.getIdentifier()).build();
if (!providerFactoriesMap.containsKey(componentIdentifier)) {
continue;
}
DefaultConfigurationParameters.Builder configurationParametersBuilder = DefaultConfigurationParameters.builder();
ConfigurationParameters configurationParameters = resolveConfigurationParameters(configurationParametersBuilder, componentConfigLine, localResolver);
ConfigurationPropertiesProvider provider = providerFactoriesMap.get(componentIdentifier).createProvider(configurationParameters, externalResourceProvider);
if (provider instanceof Component) {
Component providerComponent = (Component) provider;
TypedComponentIdentifier typedComponentIdentifier = TypedComponentIdentifier.builder().type(UNKNOWN).identifier(componentIdentifier).build();
DefaultComponentLocation.DefaultLocationPart locationPart = new DefaultComponentLocation.DefaultLocationPart(componentIdentifier.getName(), of(typedComponentIdentifier), of(configFile.getFilename()), of(configLine.getLineNumber()));
providerComponent.setAnnotations(ImmutableMap.<QName, Object>builder().put(AbstractComponent.LOCATION_KEY, new DefaultComponentLocation(of(componentIdentifier.getName()), singletonList(locationPart))).build());
}
configConfigurationPropertiesProviders.add(provider);
try {
initialiseIfNeeded(provider);
} catch (InitialisationException e) {
throw new MuleRuntimeException(e);
}
}
}));
return configConfigurationPropertiesProviders;
}
use of org.mule.runtime.dsl.api.component.config.DefaultComponentLocation in project mule by mulesoft.
the class ComponentLocationVisitor method processModuleOperationChildren.
/**
* It rewrites the history for those macro expanded operations that are not direct children from a flow, which means the
* returned {@link ComponentLocation} are mapped to the new operation rather the original flow.
*
* @param componentModel source to generate the new {@link ComponentLocation}, it also relies in its parent
* {@link ComponentModel#getParent()}
* @param operationTypedIdentifier identifier of the current operation
* @return a fictitious {@link ComponentLocation}
*/
private DefaultComponentLocation processModuleOperationChildren(ComponentModel componentModel, Optional<TypedComponentIdentifier> operationTypedIdentifier) {
final Optional<TypedComponentIdentifier> parentOperationTypedIdentifier = getModuleOperationTypeComponentIdentifier(componentModel.getParent());
final String operationName = parentOperationTypedIdentifier.get().getIdentifier().getName();
return new DefaultComponentLocation(of(operationName), emptyList()).appendLocationPart(operationName, parentOperationTypedIdentifier, componentModel.getConfigFileName(), componentModel.getLineNumber()).appendLocationPart(PROCESSORS_PART_NAME, empty(), empty(), empty()).appendLocationPart(findProcessorPath(componentModel), operationTypedIdentifier, componentModel.getConfigFileName(), componentModel.getLineNumber());
}
use of org.mule.runtime.dsl.api.component.config.DefaultComponentLocation in project mule by mulesoft.
the class MinimalApplicationModelGenerator method getMinimalModel.
/**
* Resolves the minimal set of {@link ComponentModel componentModels} for the components that pass the
* {@link LazyComponentInitializer.ComponentLocationFilter}.
*
* @param predicate to select the {@link ComponentModel componentModels} to be enabled.
* @return the generated {@link ApplicationModel} with the minimal set of {@link ComponentModel}s required.
*/
public ApplicationModel getMinimalModel(Predicate<ComponentModel> predicate) {
List<ComponentModel> required = dependencyResolver.findRequiredComponentModels(predicate);
required.stream().forEach(componentModel -> {
final DefaultComponentLocation componentLocation = componentModel.getComponentLocation();
if (componentLocation != null) {
enableComponentDependencies(componentModel);
}
});
return dependencyResolver.getApplicationModel();
}
Aggregations