|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2020 the original author or authors.
|
|
|
|
* Copyright 2012-2021 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -17,6 +17,7 @@
|
|
|
|
package org.springframework.boot.actuate.context.properties;
|
|
|
|
package org.springframework.boot.actuate.context.properties;
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Constructor;
|
|
|
|
import java.lang.reflect.Constructor;
|
|
|
|
|
|
|
|
import java.lang.reflect.Parameter;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collection;
|
|
|
@ -58,12 +59,16 @@ import org.springframework.boot.context.properties.BoundConfigurationProperties;
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationPropertiesBean;
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationPropertiesBean;
|
|
|
|
import org.springframework.boot.context.properties.ConstructorBinding;
|
|
|
|
import org.springframework.boot.context.properties.ConstructorBinding;
|
|
|
|
|
|
|
|
import org.springframework.boot.context.properties.bind.Name;
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationProperty;
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationProperty;
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
|
|
|
|
import org.springframework.boot.origin.Origin;
|
|
|
|
import org.springframework.boot.origin.Origin;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
|
|
|
|
|
import org.springframework.core.DefaultParameterNameDiscoverer;
|
|
|
|
import org.springframework.core.KotlinDetector;
|
|
|
|
import org.springframework.core.KotlinDetector;
|
|
|
|
|
|
|
|
import org.springframework.core.ParameterNameDiscoverer;
|
|
|
|
|
|
|
|
import org.springframework.core.annotation.MergedAnnotation;
|
|
|
|
import org.springframework.core.annotation.MergedAnnotations;
|
|
|
|
import org.springframework.core.annotation.MergedAnnotations;
|
|
|
|
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
|
|
|
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
|
|
|
import org.springframework.util.ClassUtils;
|
|
|
|
import org.springframework.util.ClassUtils;
|
|
|
@ -384,6 +389,8 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected static class GenericSerializerModifier extends BeanSerializerModifier {
|
|
|
|
protected static class GenericSerializerModifier extends BeanSerializerModifier {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final ParameterNameDiscoverer PARAMETER_NAME_DISCOVERER = new DefaultParameterNameDiscoverer();
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc,
|
|
|
|
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc,
|
|
|
|
List<BeanPropertyWriter> beanProperties) {
|
|
|
|
List<BeanPropertyWriter> beanProperties) {
|
|
|
@ -398,11 +405,21 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isCandidate(BeanDescription beanDesc, BeanPropertyWriter writer,
|
|
|
|
private boolean isCandidate(BeanDescription beanDesc, BeanPropertyWriter writer, Constructor<?> constructor) {
|
|
|
|
Constructor<?> bindConstructor) {
|
|
|
|
if (constructor != null) {
|
|
|
|
if (bindConstructor != null) {
|
|
|
|
Parameter[] parameters = constructor.getParameters();
|
|
|
|
return Arrays.stream(bindConstructor.getParameters())
|
|
|
|
String[] names = PARAMETER_NAME_DISCOVERER.getParameterNames(constructor);
|
|
|
|
.anyMatch((parameter) -> parameter.getName().equals(writer.getName()));
|
|
|
|
if (names == null) {
|
|
|
|
|
|
|
|
names = new String[parameters.length];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < parameters.length; i++) {
|
|
|
|
|
|
|
|
String name = MergedAnnotations.from(parameters[i]).get(Name.class)
|
|
|
|
|
|
|
|
.getValue(MergedAnnotation.VALUE, String.class)
|
|
|
|
|
|
|
|
.orElse((names[i] != null) ? names[i] : parameters[i].getName());
|
|
|
|
|
|
|
|
if (name.equals(writer.getName())) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isReadable(beanDesc, writer);
|
|
|
|
return isReadable(beanDesc, writer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|