From dfe320f172552481e08779e385236849fdfb40c5 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 25 Apr 2023 11:07:16 +0200 Subject: [PATCH] Reorganize methods in ReloadableResourceBundleMessageSource See gh-30369 --- ...ReloadableResourceBundleMessageSource.java | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java index 12e4e67cac..81fc6d1561 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java @@ -398,45 +398,6 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased } } - /** - * Resolve the specified bundle {@code filename} into a concrete {@link Resource}, - * potentially checking multiple sources or file extensions. - *

If no suitable concrete {@code Resource} can be resolved, this method - * returns a {@code Resource} for which {@link Resource#exists()} returns - * {@code false}, which gets subsequently ignored. - *

This can be leveraged to check the last modification timestamp or to load - * properties from alternative sources — for example, from an XML BLOB - * in a database, or from properties serialized using a custom format such as - * JSON. - *

The default implementation delegates to the configured - * {@link #setResourceLoader(ResourceLoader) ResourceLoader} to resolve - * resources, first checking for an existing {@code Resource} with a - * {@code .properties} extension, and otherwise returning a {@code Resource} - * with a {@code .xml} extension. - *

When overriding this method, {@link #loadProperties(Resource, String)} - * must be capable of loading properties from any type of - * {@code Resource} returned by this method. As a consequence, implementors - * are strongly encouraged to also override {@code loadProperties()}. - *

As an alternative to overriding this method, you can configure a - * {@link #setPropertiesPersister(PropertiesPersister) PropertiesPersister} - * that is capable of dealing with all resources returned by this method. - * Please note, however, that the default {@code loadProperties()} implementation - * uses {@link PropertiesPersister#loadFromXml(Properties, InputStream) loadFromXml} - * for XML resources and otherwise uses the two - * {@link PropertiesPersister#load(Properties, InputStream) load} methods - * for other types of resources. - * @param filename the bundle filename (basename + Locale) - * @return the {@code Resource} to use - * @since 6.1 - */ - protected Resource determineResource(String filename) { - Resource propertiesResource = this.resourceLoader.getResource(filename + PROPERTIES_SUFFIX); - if (propertiesResource.exists()) { - return propertiesResource; - } - return this.resourceLoader.getResource(filename + XML_SUFFIX); - } - /** * Refresh the PropertiesHolder for the given bundle filename. *

The holder can be {@code null} if not cached before, or a timed-out cache entry @@ -498,6 +459,45 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased return propHolder; } + /** + * Resolve the specified bundle {@code filename} into a concrete {@link Resource}, + * potentially checking multiple sources or file extensions. + *

If no suitable concrete {@code Resource} can be resolved, this method + * returns a {@code Resource} for which {@link Resource#exists()} returns + * {@code false}, which gets subsequently ignored. + *

This can be leveraged to check the last modification timestamp or to load + * properties from alternative sources — for example, from an XML BLOB + * in a database, or from properties serialized using a custom format such as + * JSON. + *

The default implementation delegates to the configured + * {@link #setResourceLoader(ResourceLoader) ResourceLoader} to resolve + * resources, first checking for an existing {@code Resource} with a + * {@code .properties} extension, and otherwise returning a {@code Resource} + * with a {@code .xml} extension. + *

When overriding this method, {@link #loadProperties(Resource, String)} + * must be capable of loading properties from any type of + * {@code Resource} returned by this method. As a consequence, implementors + * are strongly encouraged to also override {@code loadProperties()}. + *

As an alternative to overriding this method, you can configure a + * {@link #setPropertiesPersister(PropertiesPersister) PropertiesPersister} + * that is capable of dealing with all resources returned by this method. + * Please note, however, that the default {@code loadProperties()} implementation + * uses {@link PropertiesPersister#loadFromXml(Properties, InputStream) loadFromXml} + * for XML resources and otherwise uses the two + * {@link PropertiesPersister#load(Properties, InputStream) load} methods + * for other types of resources. + * @param filename the bundle filename (basename + Locale) + * @return the {@code Resource} to use + * @since 6.1 + */ + protected Resource determineResource(String filename) { + Resource propertiesResource = this.resourceLoader.getResource(filename + PROPERTIES_SUFFIX); + if (propertiesResource.exists()) { + return propertiesResource; + } + return this.resourceLoader.getResource(filename + XML_SUFFIX); + } + /** * Load the properties from the given resource. * @param resource the resource to load from