Search in sources :

Example 1 with BackPressureStrategyModelProperty

use of org.mule.runtime.module.extension.internal.loader.java.property.BackPressureStrategyModelProperty 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);
}
Also used : Type(org.mule.runtime.module.extension.api.loader.java.type.Type) MetadataType(org.mule.metadata.api.model.MetadataType) BackPressureStrategyModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.BackPressureStrategyModelProperty) Optional(java.util.Optional) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) IdempotentDeclarationWalker(org.mule.runtime.extension.api.declaration.fluent.util.IdempotentDeclarationWalker) SourceDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.SourceDeclaration)

Aggregations

Optional (java.util.Optional)1 MetadataType (org.mule.metadata.api.model.MetadataType)1 ExtensionDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration)1 SourceDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.SourceDeclaration)1 IdempotentDeclarationWalker (org.mule.runtime.extension.api.declaration.fluent.util.IdempotentDeclarationWalker)1 Type (org.mule.runtime.module.extension.api.loader.java.type.Type)1 BackPressureStrategyModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.BackPressureStrategyModelProperty)1 ExtensionTypeDescriptorModelProperty (org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty)1