Skip to content

Commit 38d2aa4

Browse files
Update native hints to cover proxies for key bound operations.
Also rename DataRedisRuntimeHints to RedisRuntimeHintsRegistrar. See: #2350
1 parent a55c73f commit 38d2aa4

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

src/main/java/org/springframework/data/redis/aot/DataRedisRuntimeHints.java renamed to src/main/java/org/springframework/data/redis/aot/RedisRuntimeHintsRegistrar.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@
2121
import org.springframework.aot.hint.RuntimeHints;
2222
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2323
import org.springframework.aot.hint.TypeReference;
24+
import org.springframework.data.redis.core.BoundGeoOperations;
25+
import org.springframework.data.redis.core.BoundHashOperations;
26+
import org.springframework.data.redis.core.BoundKeyOperations;
27+
import org.springframework.data.redis.core.BoundListOperations;
28+
import org.springframework.data.redis.core.BoundSetOperations;
29+
import org.springframework.data.redis.core.BoundStreamOperations;
30+
import org.springframework.data.redis.core.BoundValueOperations;
31+
import org.springframework.data.redis.core.BoundZSetOperations;
2432
import org.springframework.lang.Nullable;
2533

2634
/**
2735
* @author Christoph Strobl
2836
* @since 3.0
2937
*/
30-
public class DataRedisRuntimeHints implements RuntimeHintsRegistrar {
38+
public class RedisRuntimeHintsRegistrar implements RuntimeHintsRegistrar {
3139

3240
@Override
3341
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
@@ -107,7 +115,9 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
107115
TypeReference.of(org.springframework.data.redis.core.index.ConfigurableIndexDefinitionProvider.class),
108116
TypeReference.of(org.springframework.data.redis.core.mapping.RedisMappingContext.class),
109117
TypeReference.of(org.springframework.data.redis.repository.support.RedisRepositoryFactoryBean.class),
110-
TypeReference.of(org.springframework.data.redis.repository.query.RedisQueryCreator.class)),
118+
TypeReference.of(org.springframework.data.redis.repository.query.RedisQueryCreator.class),
119+
TypeReference.of(org.springframework.data.redis.connection.MessageListener.class),
120+
TypeReference.of(org.springframework.data.redis.listener.RedisMessageListenerContainer.class)),
111121
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
112122
MemberCategory.INVOKE_PUBLIC_METHODS));
113123

@@ -121,5 +131,28 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
121131
TypeReference.of(org.springframework.data.redis.connection.StringRedisConnection.class),
122132
TypeReference.of(org.springframework.data.redis.connection.DecoratedRedisConnection.class));
123133

134+
// keys are bound by a proxy
135+
boundOperationsProxy(BoundGeoOperations.class, hints);
136+
boundOperationsProxy(BoundHashOperations.class, hints);
137+
boundOperationsProxy(BoundKeyOperations.class, hints);
138+
boundOperationsProxy(BoundListOperations.class, hints);
139+
boundOperationsProxy(BoundSetOperations.class, hints);
140+
boundOperationsProxy(BoundStreamOperations.class, hints);
141+
boundOperationsProxy(BoundValueOperations.class, hints);
142+
boundOperationsProxy(BoundZSetOperations.class, hints);
143+
boundOperationsProxy(
144+
TypeReference.of("org.springframework.data.redis.core.BoundOperationsProxyFactory$DefaultBoundKeyOperations"),
145+
hints);
146+
}
147+
148+
private void boundOperationsProxy(Class<?> type, RuntimeHints hints) {
149+
boundOperationsProxy(TypeReference.of(type), hints);
150+
}
151+
152+
private void boundOperationsProxy(TypeReference typeReference, RuntimeHints hints) {
153+
hints.proxies().registerJdkProxy(typeReference, //
154+
TypeReference.of("org.springframework.aop.SpringProxy"), //
155+
TypeReference.of("org.springframework.aop.framework.Advised"), //
156+
TypeReference.of("org.springframework.core.DecoratingProxy"));
124157
}
125158
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
org.springframework.aot.hint.RuntimeHintsRegistrar=\
2-
org.springframework.data.redis.aot.DataRedisRuntimeHints
2+
org.springframework.data.redis.aot.RedisRuntimeHintsRegistrar

0 commit comments

Comments
 (0)