Skip to content

Commit f558822

Browse files
authored
Extend AOT runtime hints.
Original Pull Request #2579 Closes #2575
1 parent cf09e57 commit f558822

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/main/java/org/springframework/data/elasticsearch/aot/ElasticsearchRuntimeHints.java renamed to src/main/java/org/springframework/data/elasticsearch/aot/SpringDataElasticsearchRuntimeHints.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,18 @@
2727
import org.springframework.data.elasticsearch.core.event.AfterConvertCallback;
2828
import org.springframework.data.elasticsearch.core.event.AfterLoadCallback;
2929
import org.springframework.data.elasticsearch.core.event.AfterSaveCallback;
30-
import org.springframework.data.elasticsearch.core.event.AuditingEntityCallback;
3130
import org.springframework.data.elasticsearch.core.event.BeforeConvertCallback;
3231
import org.springframework.data.elasticsearch.core.event.ReactiveAfterConvertCallback;
3332
import org.springframework.data.elasticsearch.core.event.ReactiveAfterLoadCallback;
3433
import org.springframework.data.elasticsearch.core.event.ReactiveAfterSaveCallback;
35-
import org.springframework.data.elasticsearch.core.event.ReactiveAuditingEntityCallback;
3634
import org.springframework.data.elasticsearch.core.event.ReactiveBeforeConvertCallback;
37-
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
3835
import org.springframework.lang.Nullable;
3936

4037
/**
4138
* @author Peter-Josef Meisch
4239
* @since 5.1
4340
*/
44-
public class ElasticsearchRuntimeHints implements RuntimeHintsRegistrar {
41+
public class SpringDataElasticsearchRuntimeHints implements RuntimeHintsRegistrar {
4542

4643
@Override
4744
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
@@ -70,6 +67,5 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
7067

7168
// properties needed to log the different versions
7269
hints.resources().registerPattern("versions.properties");
73-
hints.resources().registerPattern("co/elastic/clients/version.properties");
7470
}
7571
}

src/main/java/org/springframework/data/elasticsearch/client/elc/aot/ElasticsearchClientRuntimeHints.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,42 @@
1515
*/
1616
package org.springframework.data.elasticsearch.client.elc.aot;
1717

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;
2022
import org.springframework.aot.hint.MemberCategory;
2123
import org.springframework.aot.hint.RuntimeHints;
2224
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2325
import org.springframework.aot.hint.TypeReference;
2426
import org.springframework.lang.Nullable;
2527

2628
/**
29+
* runtime hints for the Elasticsearch client libraries, as these do not provide any of their own.
30+
*
2731
* @author Peter-Josef Meisch
2832
* @since 5.1
2933
*/
3034
public class ElasticsearchClientRuntimeHints implements RuntimeHintsRegistrar {
3135

3236
@Override
3337
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+
;
3855
}
3956
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
org.springframework.aot.hint.RuntimeHintsRegistrar=\
2-
org.springframework.data.elasticsearch.aot.ElasticsearchRuntimeHints,\
2+
org.springframework.data.elasticsearch.aot.SpringDataElasticsearchRuntimeHints,\
33
org.springframework.data.elasticsearch.client.elc.aot.ElasticsearchClientRuntimeHints, \
44
org.springframework.data.elasticsearch.repository.aot.RepositoryRuntimeHints

0 commit comments

Comments
 (0)