Browse Source

Polish "Allow customer resolver and property sources"

See gh-26462
pull/26556/head
Stephane Nicoll 5 years ago
parent
commit
582559dd9e
  1. 8
      spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java
  2. 2
      spring-core/src/main/java/org/springframework/core/env/StandardEnvironment.java
  3. 10
      spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java
  4. 2
      spring-web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java

8
spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java vendored

@ -129,8 +129,8 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment { @@ -129,8 +129,8 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
* {@link #customizePropertySources(MutablePropertySources)} during
* construction to allow subclasses to contribute or manipulate
* {@link PropertySource} instances as appropriate.
* @see #customizePropertySources(MutablePropertySources)
* @since 5.3.4
* @see #customizePropertySources(MutablePropertySources)
*/
protected AbstractEnvironment(MutablePropertySources propertySources) {
this.propertySources = propertySources;
@ -142,17 +142,17 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment { @@ -142,17 +142,17 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
/**
* Factory method used to create the {@link ConfigurablePropertyResolver}
* instance used by the Environment.
* @see #getPropertyResolver()
* @since 5.3.4
* @see #getPropertyResolver()
*/
protected ConfigurablePropertyResolver createPropertyResolver(
MutablePropertySources propertySources) {
protected ConfigurablePropertyResolver createPropertyResolver(MutablePropertySources propertySources) {
return new PropertySourcesPropertyResolver(propertySources);
}
/**
* Return the {@link ConfigurablePropertyResolver} being used by the
* {@link Environment}.
* @since 5.3.4
* @see #createPropertyResolver(MutablePropertySources)
*/
protected final ConfigurablePropertyResolver getPropertyResolver() {

2
spring-core/src/main/java/org/springframework/core/env/StandardEnvironment.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.

10
spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java vendored

@ -131,18 +131,15 @@ class CustomEnvironmentTests { @@ -131,18 +131,15 @@ class CustomEnvironmentTests {
@Test
public void withCustomMutablePropertySources() {
class CustomMutablePropertySources extends MutablePropertySources {
}
class CustomMutablePropertySources extends MutablePropertySources {}
MutablePropertySources propertySources = new CustomMutablePropertySources();
ConfigurableEnvironment env = new AbstractEnvironment(propertySources) {
};
ConfigurableEnvironment env = new AbstractEnvironment(propertySources) {};
assertThat(env.getPropertySources()).isInstanceOf(CustomMutablePropertySources.class);
}
@Test
void withCustomPropertyResolver() {
class CustomPropertySourcesPropertyResolver extends PropertySourcesPropertyResolver {
public CustomPropertySourcesPropertyResolver(
PropertySources propertySources) {
super(propertySources);
@ -152,16 +149,13 @@ class CustomEnvironmentTests { @@ -152,16 +149,13 @@ class CustomEnvironmentTests {
public String getProperty(String key) {
return super.getProperty(key)+"-test";
}
}
ConfigurableEnvironment env = new AbstractEnvironment() {
@Override
protected ConfigurablePropertyResolver createPropertyResolver(
MutablePropertySources propertySources) {
return new CustomPropertySourcesPropertyResolver(propertySources);
}
};
Map<String, Object> values = new LinkedHashMap<>();
values.put("spring", "framework");

2
spring-web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 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.

Loading…
Cancel
Save