Rename @ConfigurationProperties attributes
Rename `name` to `prefix` and `path` to `locations`.
This commit is contained in:
@@ -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 {};
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 "";
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user