Deprecate [Property|Preferences]PlaceholderConfigurer for removal
PropertyPlaceholderConfigurer and PreferencesPlaceholderConfigurer have been officially deprecated since Spring Framework 5.2. Since we no longer expect applications to depend on these outdated mechanisms, this commit deprecates these classes "for removal" in Spring Framework 8.0. Closes gh-34880
This commit is contained in:
parent
c7787b8383
commit
33aeb6ee9c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -25,7 +25,7 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ro
|
||||||
class PropertyPlaceholderConfigurerEnvironmentIntegrationTests {
|
class PropertyPlaceholderConfigurerEnvironmentIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
void test() {
|
void test() {
|
||||||
GenericApplicationContext ctx = new GenericApplicationContext();
|
GenericApplicationContext ctx = new GenericApplicationContext();
|
||||||
ctx.registerBeanDefinition("ppc",
|
ctx.registerBeanDefinition("ppc",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -26,8 +26,8 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of PropertyPlaceholderConfigurer that supports JDK 1.4's
|
* Subclass of {@link PropertyPlaceholderConfigurer} that supports JDK 1.4's
|
||||||
* Preferences API ({@code java.util.prefs}).
|
* {@link Preferences} API.
|
||||||
*
|
*
|
||||||
* <p>Tries to resolve placeholders as keys first in the user preferences,
|
* <p>Tries to resolve placeholders as keys first in the user preferences,
|
||||||
* then in the system preferences, then in this configurer's properties.
|
* then in the system preferences, then in this configurer's properties.
|
||||||
|
@ -43,9 +43,10 @@ import org.springframework.beans.factory.InitializingBean;
|
||||||
* @see #setSystemTreePath
|
* @see #setSystemTreePath
|
||||||
* @see #setUserTreePath
|
* @see #setUserTreePath
|
||||||
* @see java.util.prefs.Preferences
|
* @see java.util.prefs.Preferences
|
||||||
* @deprecated as of 5.2, along with {@link PropertyPlaceholderConfigurer}
|
* @deprecated as of 5.2, along with {@link PropertyPlaceholderConfigurer}; to be removed in 8.0
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated(since = "5.2", forRemoval = true)
|
||||||
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigurer implements InitializingBean {
|
public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigurer implements InitializingBean {
|
||||||
|
|
||||||
private @Nullable String systemTreePath;
|
private @Nullable String systemTreePath;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -52,11 +52,13 @@ import org.springframework.util.StringValueResolver;
|
||||||
* @see #setSystemPropertiesModeName
|
* @see #setSystemPropertiesModeName
|
||||||
* @see PlaceholderConfigurerSupport
|
* @see PlaceholderConfigurerSupport
|
||||||
* @see PropertyOverrideConfigurer
|
* @see PropertyOverrideConfigurer
|
||||||
* @deprecated as of 5.2; use {@code org.springframework.context.support.PropertySourcesPlaceholderConfigurer}
|
* @deprecated as of 5.2, to be removed in 8.0;
|
||||||
* instead which is more flexible through taking advantage of the {@link org.springframework.core.env.Environment}
|
* use {@code org.springframework.context.support.PropertySourcesPlaceholderConfigurer}
|
||||||
* and {@link org.springframework.core.env.PropertySource} mechanisms.
|
* instead which is more flexible through taking advantage of the
|
||||||
|
* {@link org.springframework.core.env.Environment} and
|
||||||
|
* {@link org.springframework.core.env.PropertySource} mechanisms.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated(since = "5.2", forRemoval = true)
|
||||||
public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport {
|
public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport {
|
||||||
|
|
||||||
/** Never check system properties. */
|
/** Never check system properties. */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -44,7 +44,7 @@ import static org.springframework.beans.factory.support.BeanDefinitionReaderUtil
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
class PropertyPlaceholderConfigurerTests {
|
class PropertyPlaceholderConfigurerTests {
|
||||||
|
|
||||||
private static final String P1 = "p1";
|
private static final String P1 = "p1";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -59,7 +59,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||||
* @since 02.10.2003
|
* @since 02.10.2003
|
||||||
* @see PropertyPlaceholderConfigurerTests
|
* @see PropertyPlaceholderConfigurerTests
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
class PropertyResourceConfigurerTests {
|
class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -39,7 +39,7 @@ class PropertyPlaceholderBeanDefinitionParser extends AbstractPropertyLoadingBea
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
protected Class<?> getBeanClass(Element element) {
|
protected Class<?> getBeanClass(Element element) {
|
||||||
// The default value of system-properties-mode is 'ENVIRONMENT'. This value
|
// The default value of system-properties-mode is 'ENVIRONMENT'. This value
|
||||||
// indicates that resolution of placeholders against system properties is a
|
// indicates that resolution of placeholders against system properties is a
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -227,7 +227,7 @@ class CommonAnnotationBeanPostProcessorTests {
|
||||||
bf.registerResolvableDependency(BeanFactory.class, bf);
|
bf.registerResolvableDependency(BeanFactory.class, bf);
|
||||||
bf.registerResolvableDependency(INestedTestBean.class, (ObjectFactory<Object>) NestedTestBean::new);
|
bf.registerResolvableDependency(INestedTestBean.class, (ObjectFactory<Object>) NestedTestBean::new);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
|
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty("tb", "testBean4");
|
props.setProperty("tb", "testBean4");
|
||||||
|
@ -312,7 +312,7 @@ class CommonAnnotationBeanPostProcessorTests {
|
||||||
bf.addBeanPostProcessor(bpp);
|
bf.addBeanPostProcessor(bpp);
|
||||||
bf.registerResolvableDependency(BeanFactory.class, bf);
|
bf.registerResolvableDependency(BeanFactory.class, bf);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
|
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty("tb", "testBean3");
|
props.setProperty("tb", "testBean3");
|
||||||
|
@ -363,7 +363,7 @@ class CommonAnnotationBeanPostProcessorTests {
|
||||||
bf.addBeanPostProcessor(bpp);
|
bf.addBeanPostProcessor(bpp);
|
||||||
bf.registerResolvableDependency(BeanFactory.class, bf);
|
bf.registerResolvableDependency(BeanFactory.class, bf);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
|
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty("tb", "testBean3");
|
props.setProperty("tb", "testBean3");
|
||||||
|
|
|
@ -267,7 +267,7 @@ class ConfigurationClassProcessingTests {
|
||||||
void configurationWithPostProcessor() {
|
void configurationWithPostProcessor() {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
ctx.register(ConfigWithPostProcessor.class);
|
ctx.register(ConfigWithPostProcessor.class);
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
RootBeanDefinition placeholderConfigurer = new RootBeanDefinition(
|
RootBeanDefinition placeholderConfigurer = new RootBeanDefinition(
|
||||||
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.class);
|
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.class);
|
||||||
placeholderConfigurer.getPropertyValues().add("properties", "myProp=myValue");
|
placeholderConfigurer.getPropertyValues().add("properties", "myProp=myValue");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -68,7 +68,7 @@ import static org.springframework.context.expression.StandardBeanExpressionResol
|
||||||
class ApplicationContextExpressionTests {
|
class ApplicationContextExpressionTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
void genericApplicationContext() throws Exception {
|
void genericApplicationContext() throws Exception {
|
||||||
GenericApplicationContext ac = new GenericApplicationContext();
|
GenericApplicationContext ac = new GenericApplicationContext();
|
||||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);
|
AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -76,7 +76,7 @@ class BeanFactoryPostProcessorTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
void multipleDefinedBeanFactoryPostProcessors() {
|
void multipleDefinedBeanFactoryPostProcessors() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb1", TestBean.class);
|
ac.registerSingleton("tb1", TestBean.class);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
* @see org.springframework.beans.factory.config.PropertyResourceConfigurerTests
|
* @see org.springframework.beans.factory.config.PropertyResourceConfigurerTests
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
class PropertyResourceConfigurerIntegrationTests {
|
class PropertyResourceConfigurerIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue