Skip to content

Commit dfe320f

Browse files
committed
Reorganize methods in ReloadableResourceBundleMessageSource
See gh-30369
1 parent 2537c7c commit dfe320f

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

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

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -398,45 +398,6 @@ protected PropertiesHolder getProperties(String filename) {
398398
}
399399
}
400400

401-
/**
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)
429-
* @return the {@code Resource} to use
430-
* @since 6.1
431-
*/
432-
protected Resource determineResource(String filename) {
433-
Resource propertiesResource = this.resourceLoader.getResource(filename + PROPERTIES_SUFFIX);
434-
if (propertiesResource.exists()) {
435-
return propertiesResource;
436-
}
437-
return this.resourceLoader.getResource(filename + XML_SUFFIX);
438-
}
439-
440401
/**
441402
* Refresh the PropertiesHolder for the given bundle filename.
442403
* <p>The holder can be {@code null} if not cached before, or a timed-out cache entry
@@ -498,6 +459,45 @@ protected PropertiesHolder refreshProperties(String filename, @Nullable Properti
498459
return propHolder;
499460
}
500461

462+
/**
463+
* Resolve the specified bundle {@code filename} into a concrete {@link Resource},
464+
* potentially checking multiple sources or file extensions.
465+
* <p>If no suitable concrete {@code Resource} can be resolved, this method
466+
* returns a {@code Resource} for which {@link Resource#exists()} returns
467+
* {@code false}, which gets subsequently ignored.
468+
* <p>This can be leveraged to check the last modification timestamp or to load
469+
* properties from alternative sources &mdash; for example, from an XML BLOB
470+
* in a database, or from properties serialized using a custom format such as
471+
* JSON.
472+
* <p>The default implementation delegates to the configured
473+
* {@link #setResourceLoader(ResourceLoader) ResourceLoader} to resolve
474+
* resources, first checking for an existing {@code Resource} with a
475+
* {@code .properties} extension, and otherwise returning a {@code Resource}
476+
* with a {@code .xml} extension.
477+
* <p>When overriding this method, {@link #loadProperties(Resource, String)}
478+
* <strong>must</strong> be capable of loading properties from any type of
479+
* {@code Resource} returned by this method. As a consequence, implementors
480+
* are strongly encouraged to also override {@code loadProperties()}.
481+
* <p>As an alternative to overriding this method, you can configure a
482+
* {@link #setPropertiesPersister(PropertiesPersister) PropertiesPersister}
483+
* that is capable of dealing with all resources returned by this method.
484+
* Please note, however, that the default {@code loadProperties()} implementation
485+
* uses {@link PropertiesPersister#loadFromXml(Properties, InputStream) loadFromXml}
486+
* for XML resources and otherwise uses the two
487+
* {@link PropertiesPersister#load(Properties, InputStream) load} methods
488+
* for other types of resources.
489+
* @param filename the bundle filename (basename + Locale)
490+
* @return the {@code Resource} to use
491+
* @since 6.1
492+
*/
493+
protected Resource determineResource(String filename) {
494+
Resource propertiesResource = this.resourceLoader.getResource(filename + PROPERTIES_SUFFIX);
495+
if (propertiesResource.exists()) {
496+
return propertiesResource;
497+
}
498+
return this.resourceLoader.getResource(filename + XML_SUFFIX);
499+
}
500+
501501
/**
502502
* Load the properties from the given resource.
503503
* @param resource the resource to load from

0 commit comments

Comments
 (0)