From 2e23cf32cef1d10dff2633e60d44b57f1e689e7c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 23 Mar 2020 18:02:05 +0100 Subject: [PATCH] Clarify name generation responsibility for PropertySourceFactory impls Closes gh-24757 --- .../context/annotation/PropertySource.java | 9 ++++++--- .../core/io/support/PropertySourceFactory.java | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java b/spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java index ad7d3f41081..384197cb4e5 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java @@ -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. @@ -170,8 +170,11 @@ import org.springframework.core.io.support.PropertySourceFactory; public @interface PropertySource { /** - * Indicate the name of this property source. If omitted, a name will - * be generated based on the description of the underlying resource. + * Indicate the name of this property source. If omitted, the {@link #factory()} + * will generate a name based on the underlying resource (in the case of + * {@link org.springframework.core.io.support.DefaultPropertySourceFactory}: + * derived from the resource description through a corresponding name-less + * {@link org.springframework.core.io.support.ResourcePropertySource} constructor). * @see org.springframework.core.env.PropertySource#getName() * @see org.springframework.core.io.Resource#getDescription() */ diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PropertySourceFactory.java b/spring-core/src/main/java/org/springframework/core/io/support/PropertySourceFactory.java index 925c9a3513b..21cba7596cb 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PropertySourceFactory.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PropertySourceFactory.java @@ -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. @@ -33,6 +33,8 @@ public interface PropertySourceFactory { /** * Create a {@link PropertySource} that wraps the given resource. * @param name the name of the property source + * (can be {@code null} in which case the factory implementation + * will have to generate a name based on the given resource) * @param resource the resource (potentially encoded) to wrap * @return the new {@link PropertySource} (never {@code null}) * @throws IOException if resource resolution failed