From 3c6d10431eecdf4642d957bf59a86ef8fe9a1b3e Mon Sep 17 00:00:00 2001 From: John OHara Date: Tue, 10 Aug 2021 19:07:48 +0100 Subject: [PATCH 1/2] Efficient scan of jandex index for Spring JPA Annotations --- .../deployment/SpringDataJPAProcessor.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/SpringDataJPAProcessor.java b/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/SpringDataJPAProcessor.java index a41cfc8bfda0b..42b83a5b22238 100644 --- a/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/SpringDataJPAProcessor.java +++ b/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/SpringDataJPAProcessor.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Set; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; @@ -232,20 +233,12 @@ private List getAllInterfacesExtending(Collection targets, I } private Collection getAllNoRepositoryBeanInterfaces(IndexView index) { - Set result = new HashSet<>(); - Collection knownClasses = index.getKnownClasses(); - for (ClassInfo clazz : knownClasses) { - if (!Modifier.isInterface(clazz.flags())) { - continue; - } - boolean found = false; - for (ClassInfo classInfo : knownClasses) { - if (classInfo.classAnnotation(DotNames.SPRING_DATA_NO_REPOSITORY_BEAN) != null) { - result.add(classInfo.name()); - } - } - } - return result; + return index.getKnownClasses() + .stream() + .filter(classInfo -> Modifier.isInterface(classInfo.flags())) + .filter(classInfo -> classInfo.classAnnotation(DotNames.SPRING_DATA_NO_REPOSITORY_BEAN) != null) + .map(classInfo -> classInfo.name()) + .collect(Collectors.toSet()); } // generate a concrete class that will be used by Arc to resolve injection points From 1b56fa839ecfcfc6fac98e8691eb65965f945e84 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 10 Aug 2021 21:30:28 +0200 Subject: [PATCH 2/2] Use the index to get the NoRepositoryBean annotations --- .../spring/data/deployment/SpringDataJPAProcessor.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/SpringDataJPAProcessor.java b/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/SpringDataJPAProcessor.java index 42b83a5b22238..7ccfbb5648538 100644 --- a/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/SpringDataJPAProcessor.java +++ b/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/SpringDataJPAProcessor.java @@ -16,6 +16,7 @@ import org.eclipse.microprofile.config.ConfigProvider; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; +import org.jboss.jandex.AnnotationTarget.Kind; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; import org.jboss.jandex.IndexView; @@ -233,11 +234,10 @@ private List getAllInterfacesExtending(Collection targets, I } private Collection getAllNoRepositoryBeanInterfaces(IndexView index) { - return index.getKnownClasses() - .stream() - .filter(classInfo -> Modifier.isInterface(classInfo.flags())) - .filter(classInfo -> classInfo.classAnnotation(DotNames.SPRING_DATA_NO_REPOSITORY_BEAN) != null) - .map(classInfo -> classInfo.name()) + return index.getAnnotations(DotNames.SPRING_DATA_NO_REPOSITORY_BEAN).stream() + .filter(ai -> ai.target().kind() == Kind.CLASS) + .filter(ai -> Modifier.isInterface(ai.target().asClass().flags())) + .map(ai -> ai.target().asClass().name()) .collect(Collectors.toSet()); }