use of org.mule.runtime.app.declaration.api.RouteElementDeclaration in project mule by mulesoft.
the class DeclarationBasedElementModelFactory method createComponentElement.
private DslElementModel<? extends ComponentModel> createComponentElement(ComponentModel model, ComponentElementDeclaration<?> componentDeclaration) {
DslElementSyntax configDsl = dsl.resolve(model);
InternalComponentConfiguration.Builder configuration = InternalComponentConfiguration.builder().withIdentifier(asIdentifier(configDsl));
if (componentDeclaration instanceof ReferableElementDeclaration) {
configuration.withParameter(NAME_ATTRIBUTE_NAME, ((ReferableElementDeclaration) componentDeclaration).getRefName());
}
if (componentDeclaration.getConfigRef() != null) {
configuration.withParameter(CONFIG_ATTRIBUTE_NAME, componentDeclaration.getConfigRef());
}
DslElementModel.Builder<? extends ComponentModel> componentElement = createParameterizedElementModel(model, configDsl, componentDeclaration, configuration);
ExtensionModel componentsOwner = currentExtension;
DslSyntaxResolver componentsDslResolver = dsl;
componentDeclaration.getComponents().forEach(nestedComponentDeclaration -> {
if (nestedComponentDeclaration instanceof RouteElementDeclaration) {
if (model instanceof ComposableModel) {
((ComposableModel) model).getNestedComponents().stream().filter(nestedModel -> nestedModel instanceof NestedRouteModel && nestedModel.getName().equals(nestedComponentDeclaration.getName())).findFirst().ifPresent(nestedRouteModel -> componentElement.containing(crateRouteElement((NestedRouteModel) nestedRouteModel, (RouteElementDeclaration) nestedComponentDeclaration)));
}
} else {
create(nestedComponentDeclaration).ifPresent(nestedComponentElement -> {
nestedComponentElement.getConfiguration().ifPresent(configuration::withNestedComponent);
componentElement.containing(nestedComponentElement);
});
}
currentExtension = componentsOwner;
dsl = componentsDslResolver;
});
return componentElement.withConfig(configuration.build()).build();
}
use of org.mule.runtime.app.declaration.api.RouteElementDeclaration in project mule by mulesoft.
the class DefaultXmlArtifactDeclarationLoader method declareRoute.
private Optional<RouteElementDeclaration> declareRoute(ComposableModel model, DslElementSyntax elementDsl, ConfigLine child, ElementDeclarer extensionElementsDeclarer) {
return model.getNestedComponents().stream().filter(nestedModel -> elementDsl.getContainedElement(nestedModel.getName()).map(nestedDsl -> child.getIdentifier().equals(nestedDsl.getElementName())).orElse(false)).filter(nestedModel -> nestedModel instanceof NestedRouteModel).findFirst().map(nestedModel -> {
RouteElementDeclarer routeDeclarer = extensionElementsDeclarer.newRoute(nestedModel.getName());
DslElementSyntax routeDsl = elementDsl.getContainedElement(nestedModel.getName()).get();
declareParameterizedComponent((ParameterizedModel) nestedModel, routeDsl, routeDeclarer, child.getConfigAttributes(), child.getChildren());
declareComposableModel((ComposableModel) nestedModel, elementDsl, child, routeDeclarer);
return routeDeclarer.getDeclaration();
});
}
Aggregations