Skip to content

Commit 0fe65fe

Browse files
Add native runtime hints.
See: #445
1 parent efaeeeb commit 0fe65fe

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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.keyvalue.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.aot.hint.support.RuntimeHintsUtils;
25+
import org.springframework.data.keyvalue.annotation.KeySpace;
26+
import org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery;
27+
import org.springframework.lang.Nullable;
28+
29+
/**
30+
* @author Christoph Strobl
31+
* @since 3.0
32+
*/
33+
public class DataKeyValueRuntimeHints implements RuntimeHintsRegistrar {
34+
35+
@Override
36+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
37+
38+
// REFLECTION
39+
hints.reflection()
40+
.registerTypes(Arrays.asList(TypeReference.of(org.springframework.data.keyvalue.repository.support.SimpleKeyValueRepository.class),
41+
TypeReference.of(KeyValuePartTreeQuery.class)),
42+
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS));
43+
44+
// PROXIES
45+
RuntimeHintsUtils.registerAnnotation(hints, KeySpace.class);
46+
}
47+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.springframework.aot.hint.RuntimeHintsRegistrar=\
2+
org.springframework.data.keyvalue.aot.DataKeyValueRuntimeHints

0 commit comments

Comments
 (0)