use of org.mule.runtime.extension.api.declaration.fluent.util.IdempotentDeclarationWalker in project mule by mulesoft.
the class BackPressureDeclarationEnricher method enrich.
@Override
public void enrich(ExtensionLoadingContext extensionLoadingContext) {
final ExtensionDeclaration extensionDeclaration = extensionLoadingContext.getExtensionDeclarer().getDeclaration();
new IdempotentDeclarationWalker() {
@Override
protected void onSource(SourceDeclaration sourceDeclaration) {
BackPressureStrategyModelProperty property;
Optional<ExtensionTypeDescriptorModelProperty> extensionTypeDescriptorModelProperty = sourceDeclaration.getModelProperty(ExtensionTypeDescriptorModelProperty.class);
if (extensionTypeDescriptorModelProperty.isPresent()) {
Type sourceType = extensionTypeDescriptorModelProperty.get().getType();
property = sourceType.getAnnotation(BackPressure.class).map(BackPressureStrategyModelProperty::of).orElseGet(BackPressureStrategyModelProperty::getDefault);
sourceDeclaration.addModelProperty(property);
if (property.getSupportedModes().size() > 1) {
addBackPressureParameter(extensionDeclaration, sourceDeclaration, property);
}
}
}
}.walk(extensionDeclaration);
}
use of org.mule.runtime.extension.api.declaration.fluent.util.IdempotentDeclarationWalker in project mule by mulesoft.
the class ErrorsDeclarationEnricher method collectErrorOperations.
private List<Pair<ComponentDeclaration, MethodElement>> collectErrorOperations(ExtensionDeclaration declaration) {
List<Pair<ComponentDeclaration, MethodElement>> operations = new LinkedList<>();
new IdempotentDeclarationWalker() {
@Override
public void onOperation(WithOperationsDeclaration owner, OperationDeclaration declaration) {
addComponent(declaration);
}
@Override
protected void onConstruct(ConstructDeclaration declaration) {
addComponent(declaration);
}
private void addComponent(ComponentDeclaration<?> declaration) {
declaration.getModelProperty(ExtensionOperationDescriptorModelProperty.class).ifPresent(implementingMethodModelProperty -> operations.add(new Pair<>(declaration, implementingMethodModelProperty.getOperationMethod())));
}
}.walk(declaration);
return operations;
}
Aggregations