|
15 | 15 | */
|
16 | 16 | package org.springframework.data.elasticsearch.client.elc.aot;
|
17 | 17 |
|
18 |
| -import java.util.Arrays; |
19 |
| - |
| 18 | +import co.elastic.clients.elasticsearch._types.mapping.RuntimeFieldType; |
| 19 | +import co.elastic.clients.elasticsearch._types.mapping.TypeMapping; |
| 20 | +import co.elastic.clients.elasticsearch.indices.IndexSettings; |
| 21 | +import co.elastic.clients.elasticsearch.indices.PutMappingRequest; |
20 | 22 | import org.springframework.aot.hint.MemberCategory;
|
21 | 23 | import org.springframework.aot.hint.RuntimeHints;
|
22 | 24 | import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
23 | 25 | import org.springframework.aot.hint.TypeReference;
|
24 | 26 | import org.springframework.lang.Nullable;
|
25 | 27 |
|
26 | 28 | /**
|
| 29 | + * runtime hints for the Elasticsearch client libraries, as these do not provide any of their own. |
| 30 | + * |
27 | 31 | * @author Peter-Josef Meisch
|
28 | 32 | * @since 5.1
|
29 | 33 | */
|
30 | 34 | public class ElasticsearchClientRuntimeHints implements RuntimeHintsRegistrar {
|
31 | 35 |
|
32 | 36 | @Override
|
33 | 37 | public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
|
34 |
| - // needed for the http client used by the Elasticsearch client |
35 |
| - hints.serialization().registerType(org.apache.http.impl.auth.BasicScheme.class); |
36 |
| - hints.serialization().registerType(org.apache.http.impl.auth.RFC2617Scheme.class); |
37 |
| - hints.serialization().registerType(java.util.HashMap.class); |
| 38 | + |
| 39 | + hints.reflection() |
| 40 | + .registerType(TypeReference.of(IndexSettings.class), builder -> builder.withField("_DESERIALIZER")) // |
| 41 | + .registerType(TypeReference.of(PutMappingRequest.class), builder -> builder.withField("_DESERIALIZER")) // |
| 42 | + .registerType(TypeReference.of(RuntimeFieldType.class), builder -> builder.withField("_DESERIALIZER"))// |
| 43 | + .registerType(TypeReference.of(TypeMapping.class), builder -> builder.withField("_DESERIALIZER")) // |
| 44 | + ; |
| 45 | + |
| 46 | + hints.serialization() // |
| 47 | + .registerType(org.apache.http.impl.auth.BasicScheme.class) // |
| 48 | + .registerType(org.apache.http.impl.auth.RFC2617Scheme.class) // |
| 49 | + .registerType(java.util.HashMap.class) // |
| 50 | + ; |
| 51 | + |
| 52 | + hints.resources() // |
| 53 | + .registerPattern("co/elastic/clients/version.properties") // |
| 54 | + ; |
38 | 55 | }
|
39 | 56 | }
|
0 commit comments