Skip to content

Commit 2537c7c

Browse files
committed
Polish Javadoc in ReloadableResourceBundleMessageSource
See gh-30369
1 parent 54853ee commit 2537c7c

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -399,28 +399,35 @@ protected PropertiesHolder getProperties(String filename) {
399399
}
400400

401401
/**
402-
* Select a concrete existing {@link Resource} from a {@code bundleName}, potentially
403-
* checking multiple source (eg. file extensions). In case no suitable concrete
404-
* Resource exists this method returns a Resource for which {@link Resource#exists()}
405-
* returns {@code false}, which gets subsequently ignored.
406-
* <p>This can be leveraged to check the last modification timestamp and to load
407-
* properties from alternative sources. For example an XML blob in a database, or
408-
* properties serialized in a custom format like JSON...
409-
* <p>The default implementation first checks for an existing file Resource with the
410-
* {@code .properties} extension, and otherwise returns a file Resource with the
411-
* {@code .xml} extension.
412-
* <p>When overriding this method, {@link #loadProperties(Resource, String)} MUST be
413-
* capable of loading properties from any of the {@link Resource} this method can return.
414-
* As a consequence, implementors are strongly encouraged to also override
415-
* {@link #loadProperties(Resource, String)}.
416-
* <p>As an alternative, one could set the {@link #setPropertiesPersister(PropertiesPersister)}
417-
* with an instance capable of dealing with all resources returned by this method.
418-
* Please note however that the default {@code loadProperties} detects XML resource
419-
* filenames and uses {@link PropertiesPersister#loadFromXml(Properties, InputStream)},
420-
* and the two {@link PropertiesPersister#load(Properties, InputStream) load} methods
421-
* otherwise.
402+
* Resolve the specified bundle {@code filename} into a concrete {@link Resource},
403+
* potentially checking multiple sources or file extensions.
404+
* <p>If no suitable concrete {@code Resource} can be resolved, this method
405+
* returns a {@code Resource} for which {@link Resource#exists()} returns
406+
* {@code false}, which gets subsequently ignored.
407+
* <p>This can be leveraged to check the last modification timestamp or to load
408+
* properties from alternative sources &mdash; for example, from an XML BLOB
409+
* in a database, or from properties serialized using a custom format such as
410+
* JSON.
411+
* <p>The default implementation delegates to the configured
412+
* {@link #setResourceLoader(ResourceLoader) ResourceLoader} to resolve
413+
* resources, first checking for an existing {@code Resource} with a
414+
* {@code .properties} extension, and otherwise returning a {@code Resource}
415+
* with a {@code .xml} extension.
416+
* <p>When overriding this method, {@link #loadProperties(Resource, String)}
417+
* <strong>must</strong> be capable of loading properties from any type of
418+
* {@code Resource} returned by this method. As a consequence, implementors
419+
* are strongly encouraged to also override {@code loadProperties()}.
420+
* <p>As an alternative to overriding this method, you can configure a
421+
* {@link #setPropertiesPersister(PropertiesPersister) PropertiesPersister}
422+
* that is capable of dealing with all resources returned by this method.
423+
* Please note, however, that the default {@code loadProperties()} implementation
424+
* uses {@link PropertiesPersister#loadFromXml(Properties, InputStream) loadFromXml}
425+
* for XML resources and otherwise uses the two
426+
* {@link PropertiesPersister#load(Properties, InputStream) load} methods
427+
* for other types of resources.
428+
* @param filename the bundle filename (basename + Locale)
422429
* @return the {@code Resource} to use
423-
* @since 6.1.0
430+
* @since 6.1
424431
*/
425432
protected Resource determineResource(String filename) {
426433
Resource propertiesResource = this.resourceLoader.getResource(filename + PROPERTIES_SUFFIX);
@@ -432,10 +439,11 @@ protected Resource determineResource(String filename) {
432439

433440
/**
434441
* Refresh the PropertiesHolder for the given bundle filename.
435-
* The holder can be {@code null} if not cached before, or a timed-out cache entry
442+
* <p>The holder can be {@code null} if not cached before, or a timed-out cache entry
436443
* (potentially getting re-validated against the current last-modified timestamp).
437444
* @param filename the bundle filename (basename + Locale)
438445
* @param propHolder the current PropertiesHolder for the bundle
446+
* @see #determineResource(String)
439447
*/
440448
protected PropertiesHolder refreshProperties(String filename, @Nullable PropertiesHolder propHolder) {
441449
long refreshTimestamp = (getCacheMillis() < 0 ? -1 : System.currentTimeMillis());

0 commit comments

Comments
 (0)