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();
}
Aggregations