Extend AOT runtime hints.

Original Pull Request #2579
Closes #2575
This commit is contained in:
Peter-Josef Meisch 2023-05-31 17:57:51 +02:00 committed by GitHub
parent cf09e57736
commit f558822545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 12 deletions

View File

@ -27,21 +27,18 @@ import org.springframework.data.elasticsearch.client.elc.EntityAsMap;
import org.springframework.data.elasticsearch.core.event.AfterConvertCallback;
import org.springframework.data.elasticsearch.core.event.AfterLoadCallback;
import org.springframework.data.elasticsearch.core.event.AfterSaveCallback;
import org.springframework.data.elasticsearch.core.event.AuditingEntityCallback;
import org.springframework.data.elasticsearch.core.event.BeforeConvertCallback;
import org.springframework.data.elasticsearch.core.event.ReactiveAfterConvertCallback;
import org.springframework.data.elasticsearch.core.event.ReactiveAfterLoadCallback;
import org.springframework.data.elasticsearch.core.event.ReactiveAfterSaveCallback;
import org.springframework.data.elasticsearch.core.event.ReactiveAuditingEntityCallback;
import org.springframework.data.elasticsearch.core.event.ReactiveBeforeConvertCallback;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
import org.springframework.lang.Nullable;
/**
* @author Peter-Josef Meisch
* @since 5.1
*/
public class ElasticsearchRuntimeHints implements RuntimeHintsRegistrar {
public class SpringDataElasticsearchRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
@ -70,6 +67,5 @@ public class ElasticsearchRuntimeHints implements RuntimeHintsRegistrar {
// properties needed to log the different versions
hints.resources().registerPattern("versions.properties");
hints.resources().registerPattern("co/elastic/clients/version.properties");
}
}

View File

@ -15,8 +15,10 @@
*/
package org.springframework.data.elasticsearch.client.elc.aot;
import java.util.Arrays;
import co.elastic.clients.elasticsearch._types.mapping.RuntimeFieldType;
import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
import co.elastic.clients.elasticsearch.indices.IndexSettings;
import co.elastic.clients.elasticsearch.indices.PutMappingRequest;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
@ -24,6 +26,8 @@ import org.springframework.aot.hint.TypeReference;
import org.springframework.lang.Nullable;
/**
* runtime hints for the Elasticsearch client libraries, as these do not provide any of their own.
*
* @author Peter-Josef Meisch
* @since 5.1
*/
@ -31,9 +35,22 @@ public class ElasticsearchClientRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
// needed for the http client used by the Elasticsearch client
hints.serialization().registerType(org.apache.http.impl.auth.BasicScheme.class);
hints.serialization().registerType(org.apache.http.impl.auth.RFC2617Scheme.class);
hints.serialization().registerType(java.util.HashMap.class);
hints.reflection()
.registerType(TypeReference.of(IndexSettings.class), builder -> builder.withField("_DESERIALIZER")) //
.registerType(TypeReference.of(PutMappingRequest.class), builder -> builder.withField("_DESERIALIZER")) //
.registerType(TypeReference.of(RuntimeFieldType.class), builder -> builder.withField("_DESERIALIZER"))//
.registerType(TypeReference.of(TypeMapping.class), builder -> builder.withField("_DESERIALIZER")) //
;
hints.serialization() //
.registerType(org.apache.http.impl.auth.BasicScheme.class) //
.registerType(org.apache.http.impl.auth.RFC2617Scheme.class) //
.registerType(java.util.HashMap.class) //
;
hints.resources() //
.registerPattern("co/elastic/clients/version.properties") //
;
}
}

View File

@ -1,4 +1,4 @@
org.springframework.aot.hint.RuntimeHintsRegistrar=\
org.springframework.data.elasticsearch.aot.ElasticsearchRuntimeHints,\
org.springframework.data.elasticsearch.aot.SpringDataElasticsearchRuntimeHints,\
org.springframework.data.elasticsearch.client.elc.aot.ElasticsearchClientRuntimeHints, \
org.springframework.data.elasticsearch.repository.aot.RepositoryRuntimeHints