Rename @ConfigurationProperties attributes

Rename `name` to `prefix` and `path` to `locations`.
This commit is contained in:
Phillip Webb 2014-03-24 11:43:41 -07:00
parent 07ad45c468
commit d42bedf295
Notes: Phillip Webb 2014-03-24 23:24:46 -07:00
Fixes gh-563
36 changed files with 73 additions and 75 deletions

View File

@ -26,7 +26,7 @@ import org.springframework.util.StringUtils;
*
* @author Christian Dupuis
*/
@ConfigurationProperties(name = "endpoints.jmx")
@ConfigurationProperties(prefix = "endpoints.jmx")
public class EndpointMBeanExportProperties {
private String domain;

View File

@ -27,7 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Christian Dupuis
* @author Dave Syer
*/
@ConfigurationProperties(name = "jolokia")
@ConfigurationProperties(prefix = "jolokia")
public class JolokiaProperties {
private Map<String, String> config = new HashMap<String, String>();

View File

@ -32,7 +32,7 @@ import org.springframework.util.ClassUtils;
* @author Dave Syer
* @see ServerProperties
*/
@ConfigurationProperties(name = "management", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "management", ignoreUnknownFields = false)
public class ManagementServerProperties implements SecurityPrequisite {
private static final String SECURITY_CHECK_CLASS = "org.springframework.security.config.http.SessionCreationPolicy";

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@ -36,7 +36,7 @@ import org.springframework.util.StringUtils;
* @author Christian Dupuis
* @author Phillip Webb
*/
@ConfigurationProperties(name = "shell", ignoreUnknownFields = true)
@ConfigurationProperties(prefix = "shell", ignoreUnknownFields = true)
public class ShellProperties {
private static Log logger = LogFactory.getLog(ShellProperties.class);
@ -279,7 +279,7 @@ public class ShellProperties {
/**
* Auth specific properties for JAAS authentication
*/
@ConfigurationProperties(name = "shell.auth.jaas", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "shell.auth.jaas", ignoreUnknownFields = false)
public static class JaasAuthenticationProperties extends
CrshShellAuthenticationProperties {
@ -305,7 +305,7 @@ public class ShellProperties {
/**
* Auth specific properties for key authentication
*/
@ConfigurationProperties(name = "shell.auth.key", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "shell.auth.key", ignoreUnknownFields = false)
public static class KeyAuthenticationProperties extends
CrshShellAuthenticationProperties {
@ -333,7 +333,7 @@ public class ShellProperties {
/**
* Auth specific properties for simple authentication
*/
@ConfigurationProperties(name = "shell.auth.simple", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "shell.auth.simple", ignoreUnknownFields = false)
public static class SimpleAuthenticationProperties extends
CrshShellAuthenticationProperties {
@ -402,7 +402,7 @@ public class ShellProperties {
/**
* Auth specific properties for Spring authentication
*/
@ConfigurationProperties(name = "shell.auth.spring", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "shell.auth.spring", ignoreUnknownFields = false)
public static class SpringAuthenticationProperties extends
CrshShellAuthenticationProperties {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -43,7 +43,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
* @author Phillip Webb
* @author Dave Syer
*/
@ConfigurationProperties(name = "endpoints.autoconfig", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.autoconfig", ignoreUnknownFields = false)
public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
@Autowired

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -35,7 +35,7 @@ import org.springframework.core.env.Environment;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "endpoints.beans", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.beans", ignoreUnknownFields = false)
public class BeansEndpoint extends AbstractEndpoint<List<Object>> implements
ApplicationContextAware {

View File

@ -48,7 +48,7 @@ import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
*
* @author Christian Dupuis
*/
@ConfigurationProperties(name = "endpoints.configprops", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.configprops", ignoreUnknownFields = false)
public class ConfigurationPropertiesReportEndpoint extends
AbstractEndpoint<Map<String, Object>> implements ApplicationContextAware {
@ -138,7 +138,7 @@ public class ConfigurationPropertiesReportEndpoint extends
ConfigurationProperties annotation = AnnotationUtils.findAnnotation(
bean.getClass(), ConfigurationProperties.class);
return (StringUtils.hasLength(annotation.value()) ? annotation.value()
: annotation.name());
: annotation.prefix());
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -28,7 +28,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "endpoints.dump", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.dump", ignoreUnknownFields = false)
public class DumpEndpoint extends AbstractEndpoint<List<ThreadInfo>> {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -33,7 +33,7 @@ import org.springframework.core.env.StandardEnvironment;
* @author Dave Syer
* @author Phillip Webb
*/
@ConfigurationProperties(name = "endpoints.env", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.env", ignoreUnknownFields = false)
public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> implements
EnvironmentAware {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -25,7 +25,7 @@ import org.springframework.util.Assert;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "endpoints.health", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.health", ignoreUnknownFields = false)
public class HealthEndpoint<T> extends AbstractEndpoint<T> {
private final HealthIndicator<? extends T> indicator;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -28,7 +28,7 @@ import org.springframework.util.Assert;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "endpoints.info", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.info", ignoreUnknownFields = false)
public class InfoEndpoint extends AbstractEndpoint<Map<String, Object>> {
private final Map<String, ? extends Object> info;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -28,7 +28,7 @@ import org.springframework.util.Assert;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "endpoints.metrics", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.metrics", ignoreUnknownFields = false)
public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> {
private final PublicMetrics metrics;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -31,7 +31,7 @@ import org.springframework.context.ConfigurableApplicationContext;
* @author Dave Syer
* @author Christian Dupuis
*/
@ConfigurationProperties(name = "endpoints.shutdown", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.shutdown", ignoreUnknownFields = false)
public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> implements
ApplicationContextAware {

View File

@ -28,7 +28,7 @@ import org.springframework.util.Assert;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "endpoints.trace", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.trace", ignoreUnknownFields = false)
public class TraceEndpoint extends AbstractEndpoint<List<Trace>> {
private final TraceRepository repository;

View File

@ -42,7 +42,7 @@ import org.springframework.web.servlet.mvc.ServletWrappingController;
*
* @author Christian Dupuis
*/
@ConfigurationProperties(name = "endpoints.jolokia", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.jolokia", ignoreUnknownFields = false)
public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean,
ApplicationContextAware, ServletContextAware {

View File

@ -34,7 +34,7 @@ import org.springframework.web.context.request.RequestContextHolder;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "error")
@ConfigurationProperties(prefix = "error")
public class ManagementErrorEndpoint implements MvcEndpoint {
private final ErrorController controller;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@ -86,7 +86,7 @@ public class ConfigurationPropertiesReportEndpointParentTests {
}
@ConfigurationProperties(name = "test")
@ConfigurationProperties(prefix = "test")
public static class TestProperties {
private String myTestProperty = "654321";

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@ -104,7 +104,7 @@ public class ConfigurationPropertiesReportEndpointTests extends
}
@ConfigurationProperties(name = "test")
@ConfigurationProperties(prefix = "test")
public static class TestProperties {
private String dbPassword = "123456";

View File

@ -25,7 +25,7 @@ import org.springframework.util.StringUtils;
* @author Greg Turnquist
* @author Dave Syer
*/
@ConfigurationProperties(name = "spring.rabbitmq")
@ConfigurationProperties(prefix = "spring.rabbitmq")
public class RabbitProperties {
private String host = "localhost";

View File

@ -28,7 +28,7 @@ import org.springframework.util.StringUtils;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = DataSourceAutoConfiguration.CONFIGURATION_PREFIX)
@ConfigurationProperties(prefix = DataSourceAutoConfiguration.CONFIGURATION_PREFIX)
@EnableConfigurationProperties
public abstract class AbstractDataSourceConfiguration implements BeanClassLoaderAware,
InitializingBean {

View File

@ -23,7 +23,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* @author Greg Turnquist
*/
@ConfigurationProperties(name = "spring.activemq")
@ConfigurationProperties(prefix = "spring.activemq")
public class ActiveMQProperties {
private String brokerUrl = "tcp://localhost:61616";

View File

@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.jms;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(name = "spring.jms")
@ConfigurationProperties(prefix = "spring.jms")
public class JmsTemplateProperties {
private boolean pubSubDomain = true;

View File

@ -30,7 +30,7 @@ import com.mongodb.MongoClientURI;
* @author Dave Syer
* @author Phillip Webb
*/
@ConfigurationProperties(name = "spring.data.mongodb")
@ConfigurationProperties(prefix = "spring.data.mongodb")
public class MongoProperties {
private String host;

View File

@ -23,7 +23,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "spring.redis")
@ConfigurationProperties(prefix = "spring.redis")
public class RedisProperties {
private String host = "localhost";

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -30,7 +30,7 @@ import org.springframework.util.StringUtils;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "security", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "security", ignoreUnknownFields = false)
public class SecurityProperties implements SecurityPrequisite {
private boolean requireSsl;

View File

@ -25,7 +25,7 @@ import org.springframework.http.converter.HttpMessageConverter;
* @author Dave Syer
* @author Piotr Maj
*/
@ConfigurationProperties(name = "http.mappers", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "http.mappers", ignoreUnknownFields = false)
public class HttpMapperProperties {
private boolean jsonPrettyPrint;

View File

@ -44,7 +44,7 @@ import org.springframework.util.StringUtils;
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "server", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = false)
public class ServerProperties implements EmbeddedServletContainerCustomizer {
private Integer port;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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,7 +19,7 @@ package sample.actuator.log4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ConfigurationProperties(name = "service", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
@Component
public class ServiceProperties {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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,7 +19,7 @@ package sample.actuator;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ConfigurationProperties(name = "service", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
@Component
public class ServiceProperties {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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,7 +19,7 @@ package sample.actuator;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ConfigurationProperties(name = "service", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
@Component
public class ServiceProperties {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -18,7 +18,7 @@ package sample.integration;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(name = "service", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
public class ServiceProperties {
private String greeting = "Hello";

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -35,20 +35,18 @@ import java.lang.annotation.Target;
public @interface ConfigurationProperties {
/**
* The (optional) name of the object to be bound. Properties to bind can have a name
* prefix to select the properties that are valid to this object. Synonym for
* {@link #name()}.
* The name prefix of the properties that are valid to bind to this object. Synonym
* for {@link #prefix()}.
* @return the name prefix of the properties to bind
*/
String value() default "";
/**
* The (optional) name of the object to be bound. Properties to bind can have a name
* prefix to select the properties that are valid to this object. Synonym for
* {@link #value()}.
* The name prefix of the properties that are valid to bind to this object. Synonym
* for {@link #value()}.
* @return the name prefix of the properties to bind
*/
String name() default "";
String prefix() default "";
/**
* Flag to indicate that when binding to this object invalid fields should be ignored.
@ -80,10 +78,10 @@ public @interface ConfigurationProperties {
boolean exceptionIfInvalid() default true;
/**
* Optionally provide an explicit resource path to bind to instead of using the
* Optionally provide an explicit resource locations to bind to instead of using the
* default environment.
* @return the path (or paths) of resources to bind to
*/
String[] path() default {};
String[] locations() default {};
}

View File

@ -292,8 +292,8 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
.getTarget() : bean);
PropertiesConfigurationFactory<Object> factory = new PropertiesConfigurationFactory<Object>(
target);
if (annotation != null && annotation.path().length != 0) {
factory.setPropertySources(loadPropertySources(annotation.path()));
if (annotation != null && annotation.locations().length != 0) {
factory.setPropertySources(loadPropertySources(annotation.locations()));
}
else {
factory.setPropertySources(this.propertySources);
@ -309,7 +309,7 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
factory.setExceptionIfInvalid(annotation.exceptionIfInvalid());
factory.setIgnoreNestedProperties(annotation.ignoreNestedProperties());
String targetName = (StringUtils.hasLength(annotation.value()) ? annotation
.value() : annotation.name());
.value() : annotation.prefix());
if (StringUtils.hasLength(targetName)) {
factory.setTargetName(targetName);
}

View File

@ -83,7 +83,7 @@ class EnableConfigurationPropertiesImportSelector implements ImportSelector {
ConfigurationProperties.class);
if (annotation != null) {
return (StringUtils.hasLength(annotation.value()) ? annotation.value()
: annotation.name());
: annotation.prefix());
}
return "";
}

View File

@ -128,7 +128,7 @@ public class ConfigurationPropertiesBindingPostProcessorTests {
}
@ConfigurationProperties(name = "test")
@ConfigurationProperties(prefix = "test")
public static class PropertyWithValidatingSetter {
private String foo;
@ -157,7 +157,7 @@ public class ConfigurationPropertiesBindingPostProcessorTests {
}
@ConfigurationProperties(name = "test")
@ConfigurationProperties(prefix = "test")
public static class PropertyWithoutJSR303 implements Validator {
private String foo;
@ -215,7 +215,7 @@ public class ConfigurationPropertiesBindingPostProcessorTests {
}
@ConfigurationProperties(name = "test")
@ConfigurationProperties(prefix = "test")
public static class PropertyWithJSR303 extends PropertyWithoutJSR303 {
@NotNull

View File

@ -464,7 +464,7 @@ public class EnableConfigurationPropertiesTests {
public static class SystemExampleConfig {
}
@ConfigurationProperties(name = "external")
@ConfigurationProperties(prefix = "external")
public static class External {
private String name;
@ -478,7 +478,7 @@ public class EnableConfigurationPropertiesTests {
}
}
@ConfigurationProperties(name = "another")
@ConfigurationProperties(prefix = "another")
public static class Another {
private String name;
@ -492,7 +492,7 @@ public class EnableConfigurationPropertiesTests {
}
}
@ConfigurationProperties(name = "spring_test_external")
@ConfigurationProperties(prefix = "spring_test_external")
public static class SystemEnvVar {
public String getVal() {
@ -602,7 +602,7 @@ public class EnableConfigurationPropertiesTests {
protected static class StrictTestProperties extends TestProperties {
}
@ConfigurationProperties(name = "spring.foo")
@ConfigurationProperties(prefix = "spring.foo")
protected static class EmbeddedTestProperties extends TestProperties {
}
@ -653,7 +653,7 @@ public class EnableConfigurationPropertiesTests {
// No getter - you should be able to bind to a write-only bean
}
@ConfigurationProperties(path = "${binding.location:classpath:name.yml}")
@ConfigurationProperties(locations = "${binding.location:classpath:name.yml}")
protected static class ResourceBindingProperties {
private String name;
@ -666,7 +666,7 @@ public class EnableConfigurationPropertiesTests {
}
@EnableConfigurationProperties
@ConfigurationProperties(path = "${binding.location:classpath:map.yml}")
@ConfigurationProperties(locations = "${binding.location:classpath:map.yml}")
protected static class ResourceBindingPropertiesWithMap {
private Map<String, String> mymap;