Browse Source

Polishing

pull/25758/head
Juergen Hoeller 6 years ago
parent
commit
914425eefa
  1. 4
      spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java
  2. 5
      spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java
  3. 12
      spring-core/src/main/java/org/springframework/core/env/EnumerablePropertySource.java
  4. 4
      spring-core/src/main/java/org/springframework/core/env/PropertyResolver.java
  5. 4
      spring-core/src/main/java/org/springframework/core/env/PropertySource.java
  6. 5
      spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java
  7. 13
      spring-web/src/main/java/org/springframework/web/util/ServletContextPropertyUtils.java

4
spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java

@ -432,8 +432,7 @@ public abstract class YamlProcessor { @@ -432,8 +432,7 @@ public abstract class YamlProcessor {
/**
* {@link Constructor} that supports filtering of unsupported types.
* <p>If an unsupported type is encountered in a YAML document, an
* {@link IllegalStateException} will be thrown from {@link #getClassForName(String)}.
* @since 5.1.16
* {@link IllegalStateException} will be thrown from {@link #getClassForName}.
*/
private class FilteringConstructor extends Constructor {
@ -441,7 +440,6 @@ public abstract class YamlProcessor { @@ -441,7 +440,6 @@ public abstract class YamlProcessor {
super(loaderOptions);
}
@Override
protected Class<?> getClassForName(String name) throws ClassNotFoundException {
Assert.state(YamlProcessor.this.supportedTypes.contains(name),

5
spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -223,6 +223,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe @@ -223,6 +223,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
* @see #setIgnoreUnresolvableNestedPlaceholders
*/
protected String resolveNestedPlaceholders(String value) {
if (value.isEmpty()) {
return value;
}
return (this.ignoreUnresolvableNestedPlaceholders ?
resolvePlaceholders(value) : resolveRequiredPlaceholders(value));
}

12
spring-core/src/main/java/org/springframework/core/env/EnumerablePropertySource.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -44,10 +44,20 @@ import org.springframework.util.ObjectUtils; @@ -44,10 +44,20 @@ import org.springframework.util.ObjectUtils;
*/
public abstract class EnumerablePropertySource<T> extends PropertySource<T> {
/**
* Create a new {@code EnumerablePropertySource} with the given name and source object.
* @param name the associated name
* @param source the source object
*/
public EnumerablePropertySource(String name, T source) {
super(name, source);
}
/**
* Create a new {@code EnumerablePropertySource} with the given name and with a new
* {@code Object} instance as the underlying source.
* @param name the associated name
*/
protected EnumerablePropertySource(String name) {
super(name);
}

4
spring-core/src/main/java/org/springframework/core/env/PropertyResolver.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2020 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.
@ -98,7 +98,6 @@ public interface PropertyResolver { @@ -98,7 +98,6 @@ public interface PropertyResolver {
* @return the resolved String (never {@code null})
* @throws IllegalArgumentException if given text is {@code null}
* @see #resolveRequiredPlaceholders
* @see org.springframework.util.SystemPropertyUtils#resolvePlaceholders(String)
*/
String resolvePlaceholders(String text);
@ -109,7 +108,6 @@ public interface PropertyResolver { @@ -109,7 +108,6 @@ public interface PropertyResolver {
* @return the resolved String (never {@code null})
* @throws IllegalArgumentException if given text is {@code null}
* or if any placeholders are unresolvable
* @see org.springframework.util.SystemPropertyUtils#resolvePlaceholders(String, boolean)
*/
String resolveRequiredPlaceholders(String text) throws IllegalArgumentException;

4
spring-core/src/main/java/org/springframework/core/env/PropertySource.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -68,6 +68,8 @@ public abstract class PropertySource<T> { @@ -68,6 +68,8 @@ public abstract class PropertySource<T> {
/**
* Create a new {@code PropertySource} with the given name and source object.
* @param name the associated name
* @param source the source object
*/
public PropertySource(String name, T source) {
Assert.hasText(name, "Property source name must contain at least one character");

5
spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -78,6 +78,9 @@ public abstract class SystemPropertyUtils { @@ -78,6 +78,9 @@ public abstract class SystemPropertyUtils {
* and the "ignoreUnresolvablePlaceholders" flag is {@code false}
*/
public static String resolvePlaceholders(String text, boolean ignoreUnresolvablePlaceholders) {
if (text.isEmpty()) {
return text;
}
PropertyPlaceholderHelper helper = (ignoreUnresolvablePlaceholders ? nonStrictHelper : strictHelper);
return helper.replacePlaceholders(text, new SystemPropertyPlaceholderResolver(text));
}

13
spring-web/src/main/java/org/springframework/web/util/ServletContextPropertyUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.util;
import javax.servlet.ServletContext;
@ -73,16 +74,18 @@ public abstract class ServletContextPropertyUtils { @@ -73,16 +74,18 @@ public abstract class ServletContextPropertyUtils {
* @see SystemPropertyUtils#PLACEHOLDER_SUFFIX
* @see SystemPropertyUtils#resolvePlaceholders(String, boolean)
*/
public static String resolvePlaceholders(String text, ServletContext servletContext,
boolean ignoreUnresolvablePlaceholders) {
public static String resolvePlaceholders(
String text, ServletContext servletContext, boolean ignoreUnresolvablePlaceholders) {
if (text.isEmpty()) {
return text;
}
PropertyPlaceholderHelper helper = (ignoreUnresolvablePlaceholders ? nonStrictHelper : strictHelper);
return helper.replacePlaceholders(text, new ServletContextPlaceholderResolver(text, servletContext));
}
private static class ServletContextPlaceholderResolver
implements PropertyPlaceholderHelper.PlaceholderResolver {
private static class ServletContextPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver {
private final String text;

Loading…
Cancel
Save