|
| 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.lang.Nullable; |
| 25 | + |
| 26 | +/** |
| 27 | + * @author Christoph Strobl |
| 28 | + * @since 3.0 |
| 29 | + */ |
| 30 | +public class DataRedisRuntimeHints implements RuntimeHintsRegistrar { |
| 31 | + |
| 32 | + @Override |
| 33 | + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { |
| 34 | + |
| 35 | + // REFLECTION |
| 36 | + hints.reflection() |
| 37 | + .registerTypes( |
| 38 | + Arrays.asList(TypeReference.of(org.springframework.data.redis.connection.RedisConnection.class), |
| 39 | + TypeReference.of(org.springframework.data.redis.connection.StringRedisConnection.class), |
| 40 | + TypeReference.of(org.springframework.data.redis.connection.DefaultedRedisConnection.class), |
| 41 | + TypeReference.of(org.springframework.data.redis.connection.DefaultedRedisClusterConnection.class), |
| 42 | + TypeReference.of(org.springframework.data.redis.connection.RedisKeyCommands.class), |
| 43 | + TypeReference.of(org.springframework.data.redis.connection.RedisStringCommands.class), |
| 44 | + TypeReference.of(org.springframework.data.redis.connection.RedisListCommands.class), |
| 45 | + TypeReference.of(org.springframework.data.redis.connection.RedisSetCommands.class), |
| 46 | + TypeReference.of(org.springframework.data.redis.connection.RedisZSetCommands.class), |
| 47 | + TypeReference.of(org.springframework.data.redis.connection.RedisHashCommands.class), |
| 48 | + TypeReference.of(org.springframework.data.redis.connection.RedisTxCommands.class), |
| 49 | + TypeReference.of(org.springframework.data.redis.connection.RedisPubSubCommands.class), |
| 50 | + TypeReference.of(org.springframework.data.redis.connection.RedisConnectionCommands.class), |
| 51 | + TypeReference.of(org.springframework.data.redis.connection.RedisServerCommands.class), |
| 52 | + TypeReference.of(org.springframework.data.redis.connection.RedisStreamCommands.class), |
| 53 | + TypeReference.of(org.springframework.data.redis.connection.RedisScriptingCommands.class), |
| 54 | + TypeReference.of(org.springframework.data.redis.connection.RedisGeoCommands.class), |
| 55 | + TypeReference.of(org.springframework.data.redis.connection.RedisHyperLogLogCommands.class), |
| 56 | + TypeReference.of(org.springframework.data.redis.connection.RedisClusterCommands.class), |
| 57 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveRedisConnection.class), |
| 58 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveKeyCommands.class), |
| 59 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveStringCommands.class), |
| 60 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveListCommands.class), |
| 61 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveSetCommands.class), |
| 62 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveZSetCommands.class), |
| 63 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveHashCommands.class), |
| 64 | + TypeReference.of(org.springframework.data.redis.connection.ReactivePubSubCommands.class), |
| 65 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveServerCommands.class), |
| 66 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveStreamCommands.class), |
| 67 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveScriptingCommands.class), |
| 68 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveGeoCommands.class), |
| 69 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveHyperLogLogCommands.class), |
| 70 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterKeyCommands.class), |
| 71 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterStringCommands.class), |
| 72 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterListCommands.class), |
| 73 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterSetCommands.class), |
| 74 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterZSetCommands.class), |
| 75 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterHashCommands.class), |
| 76 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterServerCommands.class), |
| 77 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterStreamCommands.class), |
| 78 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterScriptingCommands.class), |
| 79 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterGeoCommands.class), |
| 80 | + TypeReference.of(org.springframework.data.redis.connection.ReactiveClusterHyperLogLogCommands.class), |
| 81 | + TypeReference.of(org.springframework.data.redis.core.ReactiveRedisOperations.class), |
| 82 | + TypeReference.of(org.springframework.data.redis.core.ReactiveRedisTemplate.class), |
| 83 | + TypeReference.of(org.springframework.data.redis.core.RedisOperations.class), |
| 84 | + TypeReference.of(org.springframework.data.redis.core.RedisTemplate.class), |
| 85 | + TypeReference.of(org.springframework.data.redis.core.StringRedisTemplate.class), |
| 86 | + TypeReference.of(org.springframework.data.keyvalue.annotation.KeySpace.class), |
| 87 | + TypeReference.of(org.springframework.data.keyvalue.core.AbstractKeyValueAdapter.class), |
| 88 | + TypeReference.of(org.springframework.data.keyvalue.core.KeyValueAdapter.class), |
| 89 | + TypeReference.of(org.springframework.data.keyvalue.core.KeyValueOperations.class), |
| 90 | + TypeReference.of(org.springframework.data.keyvalue.core.KeyValueTemplate.class), |
| 91 | + TypeReference.of(org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext.class), |
| 92 | + TypeReference.of(org.springframework.data.keyvalue.repository.KeyValueRepository.class), |
| 93 | + TypeReference |
| 94 | + .of(org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactoryBean.class), |
| 95 | + TypeReference.of(org.springframework.data.keyvalue.repository.config.QueryCreatorType.class), |
| 96 | + TypeReference.of(org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.class), |
| 97 | + TypeReference.of(org.springframework.data.redis.core.RedisKeyValueAdapter.class), |
| 98 | + TypeReference.of(org.springframework.data.redis.core.RedisKeyValueTemplate.class), |
| 99 | + TypeReference.of(org.springframework.data.redis.core.convert.KeyspaceConfiguration.class), |
| 100 | + TypeReference.of(org.springframework.data.redis.core.convert.MappingConfiguration.class), |
| 101 | + TypeReference.of(org.springframework.data.redis.core.convert.MappingRedisConverter.class), |
| 102 | + TypeReference.of(org.springframework.data.redis.core.convert.RedisConverter.class), |
| 103 | + TypeReference.of(org.springframework.data.redis.core.convert.RedisCustomConversions.class), |
| 104 | + TypeReference.of(org.springframework.data.redis.core.convert.ReferenceResolver.class), |
| 105 | + TypeReference.of(org.springframework.data.redis.core.convert.ReferenceResolverImpl.class), |
| 106 | + TypeReference.of(org.springframework.data.redis.core.index.IndexConfiguration.class), |
| 107 | + TypeReference.of(org.springframework.data.redis.core.index.ConfigurableIndexDefinitionProvider.class), |
| 108 | + TypeReference.of(org.springframework.data.redis.core.mapping.RedisMappingContext.class), |
| 109 | + TypeReference.of(org.springframework.data.redis.repository.support.RedisRepositoryFactoryBean.class), |
| 110 | + TypeReference.of(org.springframework.data.redis.repository.query.RedisQueryCreator.class)), |
| 111 | + hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, |
| 112 | + MemberCategory.INVOKE_PUBLIC_METHODS)); |
| 113 | + |
| 114 | + // PROXIES |
| 115 | + hints.proxies().registerJdkProxy(TypeReference.of(org.springframework.data.redis.connection.RedisConnection.class)); |
| 116 | + hints.proxies() |
| 117 | + .registerJdkProxy(TypeReference.of(org.springframework.data.redis.connection.DefaultedRedisConnection.class)); |
| 118 | + hints.proxies() |
| 119 | + .registerJdkProxy(TypeReference.of(org.springframework.data.redis.connection.ReactiveRedisConnection.class)); |
| 120 | + hints.proxies().registerJdkProxy( |
| 121 | + TypeReference.of(org.springframework.data.redis.connection.StringRedisConnection.class), |
| 122 | + TypeReference.of(org.springframework.data.redis.connection.DecoratedRedisConnection.class)); |
| 123 | + |
| 124 | + } |
| 125 | +} |
0 commit comments