Skip to content

Commit 9e9ddbf

Browse files
christophstroblmp911de
authored andcommitted
Use BindingReflectionHintsRegistrar to add reflection hints on types.
Closes: #2683 Original pull request: #2684.
1 parent 9c993e2 commit 9e9ddbf

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/main/java/org/springframework/data/aot/RepositoryRegistrationAotContribution.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,9 @@ private void contributeRepositoryInfo(AotRepositoryContext repositoryContext, Ge
268268
.registerType(repositoryInformation.getRepositoryInterface(),
269269
hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS))
270270
.registerType(repositoryInformation.getRepositoryBaseClass(),
271-
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS))
272-
.registerType(repositoryInformation.getDomainType(),
273-
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
274-
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS));
271+
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS));
272+
273+
TypeContributor.contribute(repositoryInformation.getDomainType(), contribution);
275274

276275
// Repository Fragments
277276
for (RepositoryFragment<?> fragment : getRepositoryInformation().getFragments()) {

src/main/java/org/springframework/data/aot/TypeContributor.java

+3-9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.function.Predicate;
2222

2323
import org.springframework.aot.generate.GenerationContext;
24+
import org.springframework.aot.hint.BindingReflectionHintsRegistrar;
2425
import org.springframework.aot.hint.MemberCategory;
2526
import org.springframework.core.annotation.MergedAnnotation;
2627

@@ -31,6 +32,7 @@
3132
public class TypeContributor {
3233

3334
public static final String DATA_NAMESPACE = "org.springframework.data";
35+
public static final BindingReflectionHintsRegistrar REGISTRAR = new BindingReflectionHintsRegistrar();
3436

3537
/**
3638
* Contribute the type with default reflection configuration, skip annotations.
@@ -65,15 +67,7 @@ public static void contribute(Class<?> type, Predicate<Class<? extends Annotatio
6567
return;
6668
}
6769

68-
if (type.isInterface()) {
69-
contribution.getRuntimeHints().reflection().registerType(type,
70-
hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
71-
return;
72-
}
73-
74-
contribution.getRuntimeHints().reflection().registerType(type,
75-
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS,
76-
MemberCategory.DECLARED_FIELDS));
70+
REGISTRAR.registerReflectionHints(contribution.getRuntimeHints().reflection(), type);
7771
}
7872

7973
/**

0 commit comments

Comments
 (0)