diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/Entity.java b/openmetadata-service/src/main/java/org/openmetadata/service/Entity.java index 96cac6111a4..ce5335d95e9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/Entity.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/Entity.java @@ -15,6 +15,7 @@ package org.openmetadata.service; import static org.openmetadata.common.utils.CommonUtil.listOf; import static org.openmetadata.common.utils.CommonUtil.listOrEmpty; +import static org.openmetadata.service.resources.CollectionRegistry.PACKAGES; import static org.openmetadata.service.resources.tags.TagLabelUtil.addDerivedTags; import static org.openmetadata.service.util.EntityUtil.getFlattenedEntityField; @@ -560,7 +561,11 @@ public final class Entity { /** Compile a list of REST collections based on Resource classes marked with {@code Repository} annotation */ private static List> getRepositories() { - try (ScanResult scanResult = new ClassGraph().enableAnnotationInfo().scan()) { + try (ScanResult scanResult = + new ClassGraph() + .enableAnnotationInfo() + .acceptPackages(PACKAGES.toArray(new String[0])) + .scan()) { ClassInfoList classList = scanResult.getClassesWithAnnotation(Repository.class); return classList.loadClasses(); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/CollectionRegistry.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/CollectionRegistry.java index e4e21da7f45..aa90b9865f9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/CollectionRegistry.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/CollectionRegistry.java @@ -51,6 +51,7 @@ import org.openmetadata.service.util.ReflectionUtil; */ @Slf4j public final class CollectionRegistry { + public static final List PACKAGES = List.of("org.openmetadata", "io.collate"); private static CollectionRegistry instance = null; private static volatile boolean initialized = false; @@ -110,7 +111,8 @@ public final class CollectionRegistry { * those conditions and makes it available for listing them over API to author expressions in Rules. */ private void loadConditionFunctions() { - try (ScanResult scanResult = new ClassGraph().enableAllInfo().scan()) { + try (ScanResult scanResult = + new ClassGraph().enableAllInfo().acceptPackages(PACKAGES.toArray(new String[0])).scan()) { for (ClassInfo classInfo : scanResult.getClassesWithMethodAnnotation(Function.class)) { List methods = ReflectionUtil.getMethodsAnnotatedWith(classInfo.loadClass(), Function.class); @@ -220,7 +222,11 @@ public final class CollectionRegistry { /** Compile a list of REST collections based on Resource classes marked with {@code Collection} annotation */ private static List getCollections() { - try (ScanResult scanResult = new ClassGraph().enableAnnotationInfo().scan()) { + try (ScanResult scanResult = + new ClassGraph() + .enableAnnotationInfo() + .acceptPackages(PACKAGES.toArray(new String[0])) + .scan()) { ClassInfoList classList = scanResult.getClassesWithAnnotation(Collection.class); List> collectionClasses = classList.loadClasses(); List collections = new ArrayList<>();