Commit fda537d3 authored by Phillip Webb's avatar Phillip Webb

Polish

parent e1c6860a
...@@ -149,7 +149,6 @@ class BeanDefinitionLoader { ...@@ -149,7 +149,6 @@ class BeanDefinitionLoader {
} }
private int load(Package source) { private int load(Package source) {
// FIXME register the scanned package for data to pick up
return this.scanner.scan(source.getName()); return this.scanner.scan(source.getName());
} }
......
...@@ -85,18 +85,10 @@ public class CustomPropertyConstructor extends Constructor { ...@@ -85,18 +85,10 @@ public class CustomPropertyConstructor extends Constructor {
@Override @Override
protected Property getProperty(Class<?> type, String name) protected Property getProperty(Class<?> type, String name)
throws IntrospectionException { throws IntrospectionException {
Property p = lookupProperty(type, name); Map<String, Property> forType = CustomPropertyConstructor.this.properties
.get(type);
return p != null ? p : super.getProperty(type, name); Property property = (forType == null ? null : forType.get(name));
} return (property == null ? super.getProperty(type, name) : property);
private Property lookupProperty(Class<?> type, String name) {
Map<String, Property> m = CustomPropertyConstructor.this.properties.get(type);
if (m != null) {
return m.get(name);
}
return null;
} }
} }
} }
...@@ -82,7 +82,6 @@ public class PropertiesConfigurationFactory<T> implements FactoryBean<T>, ...@@ -82,7 +82,6 @@ public class PropertiesConfigurationFactory<T> implements FactoryBean<T>,
/** /**
* Create a new factory for an object of the given type. * Create a new factory for an object of the given type.
*
* @see #PropertiesConfigurationFactory(Class) * @see #PropertiesConfigurationFactory(Class)
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
......
...@@ -44,12 +44,10 @@ public class PropertySourcesPropertyValues implements PropertyValues { ...@@ -44,12 +44,10 @@ public class PropertySourcesPropertyValues implements PropertyValues {
/** /**
* Create a new PropertyValues from the given PropertySources * Create a new PropertyValues from the given PropertySources
*
* @param propertySources a PropertySources instance * @param propertySources a PropertySources instance
*/ */
public PropertySourcesPropertyValues(PropertySources propertySources) { public PropertySourcesPropertyValues(PropertySources propertySources) {
this.propertySources = propertySources; this.propertySources = propertySources;
// TODO: maybe lazy initialization?
PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver( PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
propertySources); propertySources);
for (PropertySource<?> source : propertySources) { for (PropertySource<?> source : propertySources) {
...@@ -93,15 +91,11 @@ public class PropertySourcesPropertyValues implements PropertyValues { ...@@ -93,15 +91,11 @@ public class PropertySourcesPropertyValues implements PropertyValues {
public PropertyValues changesSince(PropertyValues old) { public PropertyValues changesSince(PropertyValues old) {
MutablePropertyValues changes = new MutablePropertyValues(); MutablePropertyValues changes = new MutablePropertyValues();
// for each property value in the new set // for each property value in the new set
for (PropertyValue newPv : getPropertyValues()) { for (PropertyValue newValue : getPropertyValues()) {
// if there wasn't an old one, add it // if there wasn't an old one, add it
PropertyValue pvOld = old.getPropertyValue(newPv.getName()); PropertyValue oldValue = old.getPropertyValue(newValue.getName());
if (pvOld == null) { if (oldValue == null || !oldValue.equals(newValue)) {
changes.addPropertyValue(newPv); changes.addPropertyValue(newValue);
}
else if (!pvOld.equals(newPv)) {
// it's changed
changes.addPropertyValue(newPv);
} }
} }
return changes; return changes;
......
...@@ -82,7 +82,6 @@ public class RelaxedDataBinder extends DataBinder { ...@@ -82,7 +82,6 @@ public class RelaxedDataBinder extends DataBinder {
* map keys. Also creates new maps for properties of map type that are null (assuming * map keys. Also creates new maps for properties of map type that are null (assuming
* all maps are potentially nested). The standard bracket <code>[...]</code> * all maps are potentially nested). The standard bracket <code>[...]</code>
* dereferencing is also accepted. * dereferencing is also accepted.
*
* @param propertyValues the property values * @param propertyValues the property values
* @param target the target object * @param target the target object
*/ */
...@@ -146,7 +145,6 @@ public class RelaxedDataBinder extends DataBinder { ...@@ -146,7 +145,6 @@ public class RelaxedDataBinder extends DataBinder {
* <li>Fuzzy matching can be employed for bean property names</li> * <li>Fuzzy matching can be employed for bean property names</li>
* <li>Period separators can be used instead of indexing ([...]) for map keys</li> * <li>Period separators can be used instead of indexing ([...]) for map keys</li>
* </ul> * </ul>
*
* @param wrapper a bean wrapper for the object to bind * @param wrapper a bean wrapper for the object to bind
* @param path the bean path to bind * @param path the bean path to bind
* @return a transformed path with correct bean wrapper syntax * @return a transformed path with correct bean wrapper syntax
......
...@@ -30,8 +30,7 @@ public abstract class JsonParserFactory { ...@@ -30,8 +30,7 @@ public abstract class JsonParserFactory {
/** /**
* Static factory for the "best" JSON parser available on the classpath. Tries Jackson * Static factory for the "best" JSON parser available on the classpath. Tries Jackson
* (2), then Snake YAML, and then falls back to the {@link SimpleJsonParser}. * 2, then Snake YAML, and then falls back to the {@link SimpleJsonParser}.
*
* @return a {@link JsonParser} * @return a {@link JsonParser}
*/ */
public static JsonParser getJsonParser() { public static JsonParser getJsonParser() {
......
...@@ -72,7 +72,6 @@ public class YamlProcessor { ...@@ -72,7 +72,6 @@ public class YamlProcessor {
* name=My Cool App * name=My Cool App
* url=http://dev.bar.com * url=http://dev.bar.com
* </pre> * </pre>
*
* @param matchers a map of keys to value patterns (regular expressions) * @param matchers a map of keys to value patterns (regular expressions)
*/ */
public void setDocumentMatchers(List<? extends DocumentMatcher> matchers) { public void setDocumentMatchers(List<? extends DocumentMatcher> matchers) {
...@@ -83,7 +82,6 @@ public class YamlProcessor { ...@@ -83,7 +82,6 @@ public class YamlProcessor {
* Flag indicating that a document for which all the * Flag indicating that a document for which all the
* {@link #setDocumentMatchers(List) document matchers} abstain will nevertheless * {@link #setDocumentMatchers(List) document matchers} abstain will nevertheless
* match. * match.
*
* @param matchDefault the flag to set (default true) * @param matchDefault the flag to set (default true)
*/ */
public void setMatchDefault(boolean matchDefault) { public void setMatchDefault(boolean matchDefault) {
...@@ -94,7 +92,6 @@ public class YamlProcessor { ...@@ -94,7 +92,6 @@ public class YamlProcessor {
* Method to use for resolving resources. Each resource will be converted to a Map, so * Method to use for resolving resources. Each resource will be converted to a Map, so
* this property is used to decide which map entries to keep in the final output from * this property is used to decide which map entries to keep in the final output from
* this factory. * this factory.
*
* @param resolutionMethod the resolution method to set (defaults to * @param resolutionMethod the resolution method to set (defaults to
* {@link ResolutionMethod#OVERRIDE}). * {@link ResolutionMethod#OVERRIDE}).
*/ */
...@@ -117,7 +114,6 @@ public class YamlProcessor { ...@@ -117,7 +114,6 @@ public class YamlProcessor {
* into the callback, along with its representation as Properties. Depending on the * into the callback, along with its representation as Properties. Depending on the
* {@link #setResolutionMethod(ResolutionMethod)} not all of the documents will be * {@link #setResolutionMethod(ResolutionMethod)} not all of the documents will be
* parsed. * parsed.
*
* @param callback a callback to delegate to once matching documents are found * @param callback a callback to delegate to once matching documents are found
*/ */
protected void process(MatchCallback callback) { protected void process(MatchCallback callback) {
......
...@@ -63,7 +63,6 @@ public class YamlPropertySourceLoader extends PropertiesPropertySourceLoader { ...@@ -63,7 +63,6 @@ public class YamlPropertySourceLoader extends PropertiesPropertySourceLoader {
/** /**
* A property source loader that loads all properties and matches all documents. * A property source loader that loads all properties and matches all documents.
*
* @return a property source loader * @return a property source loader
*/ */
public static YamlPropertySourceLoader matchAllLoader() { public static YamlPropertySourceLoader matchAllLoader() {
......
...@@ -54,7 +54,6 @@ public class ErrorPage { ...@@ -54,7 +54,6 @@ public class ErrorPage {
* The path to render (usually implemented as a forward), starting with "/". A custom * The path to render (usually implemented as a forward), starting with "/". A custom
* controller or servlet path can be used, or if the container supports it, a template * controller or servlet path can be used, or if the container supports it, a template
* path (e.g. "/error.jsp"). * path (e.g. "/error.jsp").
*
* @return the path that will be rendered for this error * @return the path that will be rendered for this error
*/ */
public String getPath() { public String getPath() {
...@@ -70,7 +69,6 @@ public class ErrorPage { ...@@ -70,7 +69,6 @@ public class ErrorPage {
/** /**
* The HTTP status value that this error page matches. * The HTTP status value that this error page matches.
*
* @return the status * @return the status
*/ */
public HttpStatus getStatus() { public HttpStatus getStatus() {
...@@ -79,7 +77,6 @@ public class ErrorPage { ...@@ -79,7 +77,6 @@ public class ErrorPage {
/** /**
* The HTTP status value that this error page matches. * The HTTP status value that this error page matches.
*
* @return the status value (or 0 for a page that matches any status) * @return the status value (or 0 for a page that matches any status)
*/ */
public int getStatusCode() { public int getStatusCode() {
...@@ -88,8 +85,7 @@ public class ErrorPage { ...@@ -88,8 +85,7 @@ public class ErrorPage {
/** /**
* The exception type name. * The exception type name.
* * @return the exception type name (or {@code null} if there is none)
* @return the exception type name (or null if there is none)
*/ */
public String getExceptionName() { public String getExceptionName() {
return this.exception == null ? null : this.exception.getName(); return this.exception == null ? null : this.exception.getName();
......
...@@ -83,7 +83,6 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer { ...@@ -83,7 +83,6 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
} }
catch (InterruptedException ex) { catch (InterruptedException ex) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
// No drama
} }
catch (Exception ex) { catch (Exception ex) {
throw new EmbeddedServletContainerException( throw new EmbeddedServletContainerException(
......
...@@ -274,7 +274,6 @@ public class JettyEmbeddedServletContainerFactory extends ...@@ -274,7 +274,6 @@ public class JettyEmbeddedServletContainerFactory extends
/** /**
* Add {@link Configuration}s that will be applied to the {@link WebAppContext} before * Add {@link Configuration}s that will be applied to the {@link WebAppContext} before
* the server is started. * the server is started.
*
* @param configurations the configurations to add * @param configurations the configurations to add
*/ */
public void addConfigurations(Configuration... configurations) { public void addConfigurations(Configuration... configurations) {
......
...@@ -332,8 +332,7 @@ public class TomcatEmbeddedServletContainerFactory extends ...@@ -332,8 +332,7 @@ public class TomcatEmbeddedServletContainerFactory extends
} }
/** /**
* Add {@link LifecycleListener}s that should be applied to the Tomcat {@link Context} * Add {@link LifecycleListener}s that should be added to the Tomcat {@link Context}.
* .
* @param contextLifecycleListeners the listeners to add * @param contextLifecycleListeners the listeners to add
*/ */
public void addContextLifecycleListeners( public void addContextLifecycleListeners(
......
...@@ -76,16 +76,14 @@ public class ContextIdApplicationContextInitializer implements ...@@ -76,16 +76,14 @@ public class ContextIdApplicationContextInitializer implements
index); index);
index = environment.getProperty("spring.application.index", Integer.class, index); index = environment.getProperty("spring.application.index", Integer.class, index);
if (index >= 0) { if (index >= 0) {
name = name + ":" + index; return name + ":" + index;
} }
else {
// FIXME do we want this
String profiles = StringUtils.arrayToCommaDelimitedString(environment String profiles = StringUtils.arrayToCommaDelimitedString(environment
.getActiveProfiles()); .getActiveProfiles());
if (StringUtils.hasText(profiles)) { if (StringUtils.hasText(profiles)) {
name = name + ":" + profiles; name = name + ":" + profiles;
} }
}
return name; return name;
} }
......
...@@ -26,9 +26,8 @@ import java.lang.annotation.Target; ...@@ -26,9 +26,8 @@ import java.lang.annotation.Target;
* Annotation for externalized configuration. Add this to a class definition if you want * Annotation for externalized configuration. Add this to a class definition if you want
* to bind and validate some external Properties (e.g. from a .properties file). * to bind and validate some external Properties (e.g. from a .properties file).
* *
* @see ConfigurationPropertiesBindingPostProcessor
*
* @author Dave Syer * @author Dave Syer
* @see ConfigurationPropertiesBindingPostProcessor
*/ */
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
...@@ -39,7 +38,6 @@ public @interface ConfigurationProperties { ...@@ -39,7 +38,6 @@ public @interface ConfigurationProperties {
* The (optional) name of the object to be bound. Properties to bind can have a name * 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 * prefix to select the properties that are valid to this object. Synonym for
* {@link #name()}. * {@link #name()}.
*
* @return the name prefix of the properties to bind * @return the name prefix of the properties to bind
*/ */
String value() default ""; String value() default "";
...@@ -48,7 +46,6 @@ public @interface ConfigurationProperties { ...@@ -48,7 +46,6 @@ public @interface ConfigurationProperties {
* The (optional) name of the object to be bound. Properties to bind can have a name * 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 * prefix to select the properties that are valid to this object. Synonym for
* {@link #value()}. * {@link #value()}.
*
* @return the name prefix of the properties to bind * @return the name prefix of the properties to bind
*/ */
String name() default ""; String name() default "";
...@@ -57,7 +54,6 @@ public @interface ConfigurationProperties { ...@@ -57,7 +54,6 @@ public @interface ConfigurationProperties {
* Flag to indicate that when binding to this object invalid fields should be ignored. * Flag to indicate that when binding to this object invalid fields should be ignored.
* Invalid means invalid according to the binder that is used, and usually this means * Invalid means invalid according to the binder that is used, and usually this means
* fields of the wrong type (or that cannot be coerced into the correct type). * fields of the wrong type (or that cannot be coerced into the correct type).
*
* @return the flag value (default false) * @return the flag value (default false)
*/ */
boolean ignoreInvalidFields() default false; boolean ignoreInvalidFields() default false;
...@@ -65,7 +61,6 @@ public @interface ConfigurationProperties { ...@@ -65,7 +61,6 @@ public @interface ConfigurationProperties {
/** /**
* Flag to indicate that when binding to this object unknown fields should be ignored. * Flag to indicate that when binding to this object unknown fields should be ignored.
* An unknown field could be a sign of a mistake in the Properties. * An unknown field could be a sign of a mistake in the Properties.
*
* @return the flag value (default true) * @return the flag value (default true)
*/ */
boolean ignoreUnknownFields() default true; boolean ignoreUnknownFields() default true;
...@@ -73,7 +68,6 @@ public @interface ConfigurationProperties { ...@@ -73,7 +68,6 @@ public @interface ConfigurationProperties {
/** /**
* Optionally provide an explicit resource path to bind to instead of using the * Optionally provide an explicit resource path to bind to instead of using the
* default environment. * default environment.
*
* @return the path (or paths) of resources to bind to * @return the path (or paths) of resources to bind to
*/ */
String[] path() default {}; String[] path() default {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment