Browse Source

Implement RuntimeHintsRegistrar

CLoses gh-44299
pull/44380/head
Tran Ngoc Nhan 12 months ago committed by Stéphane Nicoll
parent
commit
d212232d9d
  1. 12
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProvider.java
  2. 12
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProvider.java
  3. 12
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java
  4. 11
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationProperties.java
  5. 10
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/ElasticCommonSchemaProperties.java
  6. 10
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/GraylogExtendedLogFormatProperties.java
  7. 10
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonProperties.java

12
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProvider.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,6 +21,7 @@ import java.util.Arrays; @@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.List;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.boot.autoconfigure.template.PathBasedTemplateAvailabilityProvider;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar;
@ -65,16 +66,13 @@ public class FreeMarkerTemplateAvailabilityProvider extends PathBasedTemplateAva @@ -65,16 +66,13 @@ public class FreeMarkerTemplateAvailabilityProvider extends PathBasedTemplateAva
}
static class FreeMarkerTemplateAvailabilityRuntimeHints extends BindableRuntimeHintsRegistrar {
FreeMarkerTemplateAvailabilityRuntimeHints() {
super(FreeMarkerTemplateAvailabilityProperties.class);
}
static class FreeMarkerTemplateAvailabilityRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
if (ClassUtils.isPresent(REQUIRED_CLASS_NAME, classLoader)) {
super.registerHints(hints, classLoader);
BindableRuntimeHintsRegistrar.forTypes(FreeMarkerTemplateAvailabilityProperties.class)
.registerHints(hints, classLoader);
}
}

12
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProvider.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,6 +21,7 @@ import java.util.Arrays; @@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.List;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.boot.autoconfigure.template.PathBasedTemplateAvailabilityProvider;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar;
@ -65,16 +66,13 @@ public class GroovyTemplateAvailabilityProvider extends PathBasedTemplateAvailab @@ -65,16 +66,13 @@ public class GroovyTemplateAvailabilityProvider extends PathBasedTemplateAvailab
}
static class GroovyTemplateAvailabilityRuntimeHints extends BindableRuntimeHintsRegistrar {
GroovyTemplateAvailabilityRuntimeHints() {
super(GroovyTemplateAvailabilityProperties.class);
}
static class GroovyTemplateAvailabilityRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
if (ClassUtils.isPresent(REQUIRED_CLASS_NAME, classLoader)) {
super.registerHints(hints, classLoader);
BindableRuntimeHintsRegistrar.forTypes(GroovyTemplateAvailabilityProperties.class)
.registerHints(hints, classLoader);
}
}

12
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.http;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -31,6 +33,7 @@ import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; @@ -31,6 +33,7 @@ import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration;
import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.logging.structured.GraylogExtendedLogFormatProperties;
import org.springframework.boot.web.servlet.server.Encoding;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
@ -100,10 +103,11 @@ public class HttpMessageConvertersAutoConfiguration { @@ -100,10 +103,11 @@ public class HttpMessageConvertersAutoConfiguration {
}
static class HttpMessageConvertersAutoConfigurationRuntimeHints extends BindableRuntimeHintsRegistrar {
static class HttpMessageConvertersAutoConfigurationRuntimeHints implements RuntimeHintsRegistrar {
HttpMessageConvertersAutoConfigurationRuntimeHints() {
super(Encoding.class);
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
BindableRuntimeHintsRegistrar.forTypes(Encoding.class).registerHints(hints, classLoader);
}
}

11
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationProperties.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,6 +19,8 @@ package org.springframework.boot; @@ -19,6 +19,8 @@ package org.springframework.boot;
import java.util.LinkedHashSet;
import java.util.Set;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.boot.Banner.Mode;
import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar;
import org.springframework.boot.logging.LoggingSystemProperty;
@ -157,10 +159,11 @@ class ApplicationProperties { @@ -157,10 +159,11 @@ class ApplicationProperties {
this.webApplicationType = webApplicationType;
}
static class ApplicationPropertiesRuntimeHints extends BindableRuntimeHintsRegistrar {
static class ApplicationPropertiesRuntimeHints implements RuntimeHintsRegistrar {
ApplicationPropertiesRuntimeHints() {
super(ApplicationProperties.class);
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
BindableRuntimeHintsRegistrar.forTypes(ApplicationProperties.class).registerHints(hints, classLoader);
}
}

10
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/ElasticCommonSchemaProperties.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.boot.logging.structured;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.json.JsonWriter;
@ -92,10 +94,12 @@ public record ElasticCommonSchemaProperties(Service service) { @@ -92,10 +94,12 @@ public record ElasticCommonSchemaProperties(Service service) {
}
static class ElasticCommonSchemaPropertiesRuntimeHints extends BindableRuntimeHintsRegistrar {
static class ElasticCommonSchemaPropertiesRuntimeHints implements RuntimeHintsRegistrar {
ElasticCommonSchemaPropertiesRuntimeHints() {
super(ElasticCommonSchemaProperties.class);
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
BindableRuntimeHintsRegistrar.forTypes(ElasticCommonSchemaProperties.class)
.registerHints(hints, classLoader);
}
}

10
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/GraylogExtendedLogFormatProperties.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.boot.logging.structured;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.json.JsonWriter;
@ -92,10 +94,12 @@ public record GraylogExtendedLogFormatProperties(String host, Service service) { @@ -92,10 +94,12 @@ public record GraylogExtendedLogFormatProperties(String host, Service service) {
}
static class GraylogExtendedLogFormatPropertiesRuntimeHints extends BindableRuntimeHintsRegistrar {
static class GraylogExtendedLogFormatPropertiesRuntimeHints implements RuntimeHintsRegistrar {
GraylogExtendedLogFormatPropertiesRuntimeHints() {
super(GraylogExtendedLogFormatProperties.class);
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
BindableRuntimeHintsRegistrar.forTypes(GraylogExtendedLogFormatProperties.class)
.registerHints(hints, classLoader);
}
}

10
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonProperties.java

@ -19,6 +19,8 @@ package org.springframework.boot.logging.structured; @@ -19,6 +19,8 @@ package org.springframework.boot.logging.structured;
import java.util.Map;
import java.util.Set;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.core.env.Environment;
@ -43,10 +45,12 @@ record StructuredLoggingJsonProperties(Set<String> include, Set<String> exclude, @@ -43,10 +45,12 @@ record StructuredLoggingJsonProperties(Set<String> include, Set<String> exclude,
.orElse(null);
}
static class StructuredLoggingJsonPropertiesRuntimeHints extends BindableRuntimeHintsRegistrar {
static class StructuredLoggingJsonPropertiesRuntimeHints implements RuntimeHintsRegistrar {
StructuredLoggingJsonPropertiesRuntimeHints() {
super(StructuredLoggingJsonProperties.class);
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
BindableRuntimeHintsRegistrar.forTypes(StructuredLoggingJsonProperties.class)
.registerHints(hints, classLoader);
}
}

Loading…
Cancel
Save