Provide native hints to create transaction proxies at runtime.

Closes: #4221
This commit is contained in:
Christoph Strobl
2022-10-27 17:14:28 +02:00
parent 521bbd2535
commit 88ea57f2be

View File

@@ -32,6 +32,7 @@ import org.springframework.data.mongodb.core.mapping.event.ReactiveAfterSaveCall
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeConvertCallback; import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeConvertCallback;
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeSaveCallback; import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeSaveCallback;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
/** /**
* {@link RuntimeHintsRegistrar} for repository types and entity callbacks. * {@link RuntimeHintsRegistrar} for repository types and entity callbacks.
@@ -51,6 +52,16 @@ class MongoRuntimeHints implements RuntimeHintsRegistrar {
builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_PUBLIC_METHODS)); MemberCategory.INVOKE_PUBLIC_METHODS));
if (ClassUtils.isPresent("org.springframework.aop.SpringProxy", classLoader)) {
hints.proxies().registerJdkProxy(TypeReference.of(com.mongodb.client.MongoDatabase.class),
TypeReference.of("org.springframework.aop.SpringProxy"),
TypeReference.of("org.springframework.core.DecoratingProxy"));
hints.proxies().registerJdkProxy(TypeReference.of(com.mongodb.client.MongoCollection.class),
TypeReference.of("org.springframework.aop.SpringProxy"),
TypeReference.of("org.springframework.core.DecoratingProxy"));
}
if (isReactorPresent()) { if (isReactorPresent()) {
hints.reflection() hints.reflection()