Search in sources :

Example 1 with DeclarationEnrichers

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

the class AbstractJavaExtensionModelLoader method getPrivilegedDeclarationEnrichers.

private Collection<DeclarationEnricher> getPrivilegedDeclarationEnrichers(ExtensionLoadingContext context) {
    ExtensionElement extensionType = getExtensionType(context);
    if (extensionType.getDeclaringClass().isPresent()) {
        try {
            // TODO: MULE-12744. If this call throws an exception it means that the extension cannot access the privileged API.
            ClassLoader extensionClassLoader = context.getExtensionClassLoader();
            Class annotation = extensionClassLoader.loadClass(DeclarationEnrichers.class.getName());
            return (Collection<DeclarationEnricher>) extensionType.getAnnotation((Class<DeclarationEnrichers>) annotation).map(enrichers -> withContextClassLoader(extensionClassLoader, () -> stream(enrichers.value()).map(this::instantiateOrFail).collect(toList()))).orElse(emptyList());
        } catch (ClassNotFoundException e) {
        // Do nothing
        }
    }
    return emptyList();
}
Also used : ExtensionElement(org.mule.runtime.module.extension.api.loader.java.type.ExtensionElement) ClassUtils.withContextClassLoader(org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader) Collection(java.util.Collection) ClassUtils.loadClass(org.mule.runtime.core.api.util.ClassUtils.loadClass) DeclarationEnrichers(org.mule.runtime.extension.api.annotation.privileged.DeclarationEnrichers)

Aggregations

Collection (java.util.Collection)1 ClassUtils.loadClass (org.mule.runtime.core.api.util.ClassUtils.loadClass)1 ClassUtils.withContextClassLoader (org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader)1 DeclarationEnrichers (org.mule.runtime.extension.api.annotation.privileged.DeclarationEnrichers)1 ExtensionElement (org.mule.runtime.module.extension.api.loader.java.type.ExtensionElement)1