Improve registration of the same hint for multiple classes

Based on the feedback in #28977 an easy way to create a list of
type references based on a vararg of classes is helpful when
registering the same hints for several types.
This commit is contained in:
Stephane Nicoll
2022-08-18 06:52:34 +02:00
parent 4556895e6e
commit d6afa8df2d
11 changed files with 158 additions and 124 deletions

View File

@@ -16,8 +16,6 @@
package org.springframework.transaction.annotation;
import java.util.List;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
@@ -38,11 +36,8 @@ class TransactionRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
RuntimeHintsUtils.registerSynthesizedAnnotation(hints, Transactional.class);
hints.reflection()
.registerTypes(List.of(
TypeReference.of(Isolation.class),
TypeReference.of(Propagation.class),
TypeReference.of(TransactionDefinition.class)),
builder -> builder.withMembers(MemberCategory.DECLARED_FIELDS));
hints.reflection().registerTypes(TypeReference.listOf(
Isolation.class, Propagation.class, TransactionDefinition.class),
builder -> builder.withMembers(MemberCategory.DECLARED_FIELDS));
}
}