use of org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage in project mule by mulesoft.
the class ApplicationModel method resolveComponentTypes.
/**
* Resolves the types of each component model when possible.
*/
public void resolveComponentTypes() {
// TODO MULE-13894 enable this once changes are completed and no componentBuildingDefinition is needed
// checkState(componentBuildingDefinitionRegistry.isPresent(),
// "ApplicationModel was created without a " + ComponentBuildingDefinitionProvider.class.getName());
componentBuildingDefinitionRegistry.ifPresent(buildingDefinitionRegistry -> {
executeOnEveryComponentTree(componentModel -> {
Optional<ComponentBuildingDefinition<?>> buildingDefinition = buildingDefinitionRegistry.getBuildingDefinition(componentModel.getIdentifier());
buildingDefinition.map(definition -> {
ObjectTypeVisitor typeDefinitionVisitor = new ObjectTypeVisitor(componentModel);
definition.getTypeDefinition().visit(typeDefinitionVisitor);
componentModel.setType(typeDefinitionVisitor.getType());
return definition;
}).orElseGet(() -> {
String classParameter = componentModel.getParameters().get(CLASS_ATTRIBUTE);
if (classParameter != null) {
try {
componentModel.setType(ClassUtils.getClass(classParameter));
} catch (ClassNotFoundException e) {
throw new RuntimeConfigurationException(I18nMessageFactory.createStaticMessage(String.format("Could not resolve class '%s' for component '%s'", classParameter, componentModel.getComponentLocation())));
}
}
return null;
});
});
});
}
Aggregations