Skip to content

Commit 714f0e5

Browse files
committed
Polishing
Adopt new naming scheme, replace fqcn with imported ones. See #2350
1 parent 738d37b commit 714f0e5

File tree

3 files changed

+139
-159
lines changed

3 files changed

+139
-159
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.redis.aot;
17+
18+
import java.util.Arrays;
19+
20+
import org.springframework.aot.hint.MemberCategory;
21+
import org.springframework.aot.hint.RuntimeHints;
22+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
23+
import org.springframework.aot.hint.TypeReference;
24+
import org.springframework.data.keyvalue.annotation.KeySpace;
25+
import org.springframework.data.keyvalue.core.AbstractKeyValueAdapter;
26+
import org.springframework.data.keyvalue.core.KeyValueAdapter;
27+
import org.springframework.data.keyvalue.core.KeyValueOperations;
28+
import org.springframework.data.keyvalue.core.KeyValueTemplate;
29+
import org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext;
30+
import org.springframework.data.keyvalue.repository.KeyValueRepository;
31+
import org.springframework.data.keyvalue.repository.config.QueryCreatorType;
32+
import org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery;
33+
import org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactoryBean;
34+
import org.springframework.data.redis.connection.*;
35+
import org.springframework.data.redis.core.*;
36+
import org.springframework.data.redis.core.convert.KeyspaceConfiguration;
37+
import org.springframework.data.redis.core.convert.MappingConfiguration;
38+
import org.springframework.data.redis.core.convert.MappingRedisConverter;
39+
import org.springframework.data.redis.core.convert.RedisConverter;
40+
import org.springframework.data.redis.core.convert.RedisCustomConversions;
41+
import org.springframework.data.redis.core.convert.ReferenceResolver;
42+
import org.springframework.data.redis.core.convert.ReferenceResolverImpl;
43+
import org.springframework.data.redis.core.index.ConfigurableIndexDefinitionProvider;
44+
import org.springframework.data.redis.core.index.IndexConfiguration;
45+
import org.springframework.data.redis.core.mapping.RedisMappingContext;
46+
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
47+
import org.springframework.data.redis.repository.query.RedisQueryCreator;
48+
import org.springframework.data.redis.repository.support.RedisRepositoryFactoryBean;
49+
import org.springframework.lang.Nullable;
50+
51+
/**
52+
* {@link RuntimeHintsRegistrar} for Redis operations and repository support.
53+
*
54+
* @author Christoph Strobl
55+
* @since 3.0
56+
*/
57+
class RedisRuntimeHints implements RuntimeHintsRegistrar {
58+
59+
@Override
60+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
61+
62+
// REFLECTION
63+
hints.reflection().registerTypes(Arrays.asList(TypeReference.of(RedisConnection.class),
64+
TypeReference.of(StringRedisConnection.class), TypeReference.of(DefaultedRedisConnection.class),
65+
TypeReference.of(DefaultedRedisClusterConnection.class), TypeReference.of(RedisKeyCommands.class),
66+
TypeReference.of(RedisStringCommands.class), TypeReference.of(RedisListCommands.class),
67+
TypeReference.of(RedisSetCommands.class), TypeReference.of(RedisZSetCommands.class),
68+
TypeReference.of(RedisHashCommands.class), TypeReference.of(RedisTxCommands.class),
69+
TypeReference.of(RedisPubSubCommands.class), TypeReference.of(RedisConnectionCommands.class),
70+
TypeReference.of(RedisServerCommands.class), TypeReference.of(RedisStreamCommands.class),
71+
TypeReference.of(RedisScriptingCommands.class), TypeReference.of(RedisGeoCommands.class),
72+
TypeReference.of(RedisHyperLogLogCommands.class), TypeReference.of(RedisClusterCommands.class),
73+
TypeReference.of(ReactiveRedisConnection.class), TypeReference.of(ReactiveKeyCommands.class),
74+
TypeReference.of(ReactiveStringCommands.class), TypeReference.of(ReactiveListCommands.class),
75+
TypeReference.of(ReactiveSetCommands.class), TypeReference.of(ReactiveZSetCommands.class),
76+
TypeReference.of(ReactiveHashCommands.class), TypeReference.of(ReactivePubSubCommands.class),
77+
TypeReference.of(ReactiveServerCommands.class), TypeReference.of(ReactiveStreamCommands.class),
78+
TypeReference.of(ReactiveScriptingCommands.class), TypeReference.of(ReactiveGeoCommands.class),
79+
TypeReference.of(ReactiveHyperLogLogCommands.class), TypeReference.of(ReactiveClusterKeyCommands.class),
80+
TypeReference.of(ReactiveClusterStringCommands.class), TypeReference.of(ReactiveClusterListCommands.class),
81+
TypeReference.of(ReactiveClusterSetCommands.class), TypeReference.of(ReactiveClusterZSetCommands.class),
82+
TypeReference.of(ReactiveClusterHashCommands.class), TypeReference.of(ReactiveClusterServerCommands.class),
83+
TypeReference.of(ReactiveClusterStreamCommands.class), TypeReference.of(ReactiveClusterScriptingCommands.class),
84+
TypeReference.of(ReactiveClusterGeoCommands.class), TypeReference.of(ReactiveClusterHyperLogLogCommands.class),
85+
TypeReference.of(ReactiveRedisOperations.class), TypeReference.of(ReactiveRedisTemplate.class),
86+
TypeReference.of(RedisOperations.class), TypeReference.of(RedisTemplate.class),
87+
TypeReference.of(StringRedisTemplate.class), TypeReference.of(KeyspaceConfiguration.class),
88+
TypeReference.of(MappingConfiguration.class), TypeReference.of(MappingRedisConverter.class),
89+
TypeReference.of(RedisConverter.class), TypeReference.of(RedisCustomConversions.class),
90+
TypeReference.of(ReferenceResolver.class), TypeReference.of(ReferenceResolverImpl.class),
91+
TypeReference.of(IndexConfiguration.class), TypeReference.of(ConfigurableIndexDefinitionProvider.class),
92+
TypeReference.of(RedisMappingContext.class), TypeReference.of(RedisRepositoryFactoryBean.class),
93+
TypeReference.of(RedisQueryCreator.class), TypeReference.of(MessageListener.class),
94+
TypeReference.of(RedisMessageListenerContainer.class),
95+
96+
TypeReference.of(RedisKeyValueAdapter.class), TypeReference.of(RedisKeyValueTemplate.class),
97+
98+
// Key-Value
99+
TypeReference.of(KeySpace.class), TypeReference.of(AbstractKeyValueAdapter.class),
100+
TypeReference.of(KeyValueAdapter.class), TypeReference.of(KeyValueOperations.class),
101+
TypeReference.of(KeyValueTemplate.class), TypeReference.of(KeyValueMappingContext.class),
102+
TypeReference.of(KeyValueRepository.class), TypeReference.of(KeyValueRepositoryFactoryBean.class),
103+
TypeReference.of(QueryCreatorType.class), TypeReference.of(KeyValuePartTreeQuery.class)),
104+
105+
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS));
106+
107+
// PROXIES
108+
hints.proxies().registerJdkProxy(TypeReference.of(RedisConnection.class));
109+
hints.proxies().registerJdkProxy(TypeReference.of(DefaultedRedisConnection.class));
110+
hints.proxies().registerJdkProxy(TypeReference.of(ReactiveRedisConnection.class));
111+
hints.proxies().registerJdkProxy(TypeReference.of(StringRedisConnection.class),
112+
TypeReference.of(DecoratedRedisConnection.class));
113+
114+
// keys are bound by a proxy
115+
boundOperationsProxy(BoundGeoOperations.class, hints);
116+
boundOperationsProxy(BoundHashOperations.class, hints);
117+
boundOperationsProxy(BoundKeyOperations.class, hints);
118+
boundOperationsProxy(BoundListOperations.class, hints);
119+
boundOperationsProxy(BoundSetOperations.class, hints);
120+
boundOperationsProxy(BoundStreamOperations.class, hints);
121+
boundOperationsProxy(BoundValueOperations.class, hints);
122+
boundOperationsProxy(BoundZSetOperations.class, hints);
123+
boundOperationsProxy(
124+
TypeReference.of("org.springframework.data.redis.core.BoundOperationsProxyFactory$DefaultBoundKeyOperations"),
125+
hints);
126+
}
127+
128+
private void boundOperationsProxy(Class<?> type, RuntimeHints hints) {
129+
boundOperationsProxy(TypeReference.of(type), hints);
130+
}
131+
132+
private void boundOperationsProxy(TypeReference typeReference, RuntimeHints hints) {
133+
hints.proxies().registerJdkProxy(typeReference, //
134+
TypeReference.of("org.springframework.aop.SpringProxy"), //
135+
TypeReference.of("org.springframework.aop.framework.Advised"), //
136+
TypeReference.of("org.springframework.core.DecoratingProxy"));
137+
}
138+
}

src/main/java/org/springframework/data/redis/aot/RedisRuntimeHintsRegistrar.java

Lines changed: 0 additions & 158 deletions
This file was deleted.
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.RedisRuntimeHintsRegistrar
2+
org.springframework.data.redis.aot.RedisRuntimeHints

0 commit comments

Comments
 (0)