Search in sources :

Example 1 with Export

use of org.mule.runtime.extension.api.annotation.Export in project mule by mulesoft.

the class JavaExportedTypesDeclarationEnricher method enrich.

@Override
public void enrich(ExtensionLoadingContext extensionLoadingContext) {
    Optional<ExtensionTypeDescriptorModelProperty> modelProperty = extensionLoadingContext.getExtensionDeclarer().getDeclaration().getModelProperty(ExtensionTypeDescriptorModelProperty.class);
    modelProperty.map(ExtensionTypeDescriptorModelProperty::getType).flatMap(type -> type.getValueFromAnnotation(Export.class)).ifPresent(exportAnnotation -> {
        ExtensionDeclarer declarer = extensionLoadingContext.getExtensionDeclarer();
        exportAnnotation.getClassArrayValue(Export::classes).stream().map(Type::asMetadataType).forEach(type -> registerType(declarer, type));
        exportAnnotation.getArrayValue(Export::resources).forEach(declarer::withResource);
    });
}
Also used : ObjectType(org.mule.metadata.api.model.ObjectType) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) DeclarationEnricherPhase(org.mule.runtime.extension.api.loader.DeclarationEnricherPhase) ExtensionLoadingContext(org.mule.runtime.extension.api.loader.ExtensionLoadingContext) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) Export(org.mule.runtime.extension.api.annotation.Export) Type(org.mule.runtime.module.extension.api.loader.java.type.Type) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) ArrayType(org.mule.metadata.api.model.ArrayType) IntersectionType(org.mule.metadata.api.model.IntersectionType) MetadataType(org.mule.metadata.api.model.MetadataType) Optional(java.util.Optional) UnionType(org.mule.metadata.api.model.UnionType) ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) INITIALIZE(org.mule.runtime.extension.api.loader.DeclarationEnricherPhase.INITIALIZE) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer)

Aggregations

Optional (java.util.Optional)1 ArrayType (org.mule.metadata.api.model.ArrayType)1 IntersectionType (org.mule.metadata.api.model.IntersectionType)1 MetadataType (org.mule.metadata.api.model.MetadataType)1 ObjectFieldType (org.mule.metadata.api.model.ObjectFieldType)1 ObjectType (org.mule.metadata.api.model.ObjectType)1 UnionType (org.mule.metadata.api.model.UnionType)1 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)1 ExtensionDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer)1 Export (org.mule.runtime.extension.api.annotation.Export)1 DeclarationEnricherPhase (org.mule.runtime.extension.api.loader.DeclarationEnricherPhase)1 INITIALIZE (org.mule.runtime.extension.api.loader.DeclarationEnricherPhase.INITIALIZE)1 ExtensionLoadingContext (org.mule.runtime.extension.api.loader.ExtensionLoadingContext)1 Type (org.mule.runtime.module.extension.api.loader.java.type.Type)1 ExtensionTypeDescriptorModelProperty (org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty)1