@@ -131,7 +131,7 @@ public static ResourceLoader get(ResourceLoader resourceLoader) {
131131 * class loader at the time this call is made.
132132 * @param resourceLoader the delegate resource loader
133133 * @param preferFileResolution if file based resolution is preferred when a suitable
134- * {@link ResourceFilePathResolver } support the resource
134+ * {@link FilePathResolver } support the resource
135135 * @return a {@link ResourceLoader} instance
136136 * @since 3.4.1
137137 */
@@ -160,8 +160,8 @@ private static ResourceLoader get(ResourceLoader resourceLoader, SpringFactories
160160 Assert .notNull (resourceLoader , "'resourceLoader' must not be null" );
161161 Assert .notNull (springFactoriesLoader , "'springFactoriesLoader' must not be null" );
162162 List <ProtocolResolver > protocolResolvers = springFactoriesLoader .load (ProtocolResolver .class );
163- List <ResourceFilePathResolver > filePathResolvers = (preferFileResolution )
164- ? springFactoriesLoader .load (ResourceFilePathResolver .class ) : Collections .emptyList ();
163+ List <FilePathResolver > filePathResolvers = (preferFileResolution )
164+ ? springFactoriesLoader .load (FilePathResolver .class ) : Collections .emptyList ();
165165 return new ProtocolResolvingResourceLoader (resourceLoader , protocolResolvers , filePathResolvers );
166166 }
167167
@@ -188,6 +188,28 @@ static ResourceLoader get(ClassLoader classLoader) {
188188
189189 }
190190
191+ /**
192+ * Strategy interface registered in {@code spring.factories} and used by
193+ * {@link ApplicationResourceLoader} to determine the file path of loaded resource
194+ * when it can also be represented as a {@link FileSystemResource}.
195+ *
196+ * @author Phillip Webb
197+ * @since 3.4.5
198+ */
199+ public interface FilePathResolver {
200+
201+ /**
202+ * Return the {@code path} of the given resource if it can also be represented as
203+ * a {@link FileSystemResource}.
204+ * @param location the location used to create the resource
205+ * @param resource the resource to check
206+ * @return the file path of the resource or {@code null} if the it is not possible
207+ * to represent the resource as a {@link FileSystemResource}.
208+ */
209+ String resolveFilePath (String location , Resource resource );
210+
211+ }
212+
191213 /**
192214 * An application {@link Resource}.
193215 */
@@ -214,10 +236,10 @@ private static class ProtocolResolvingResourceLoader implements ResourceLoader {
214236
215237 private final List <ProtocolResolver > protocolResolvers ;
216238
217- private final List <ResourceFilePathResolver > filePathResolvers ;
239+ private final List <FilePathResolver > filePathResolvers ;
218240
219241 ProtocolResolvingResourceLoader (ResourceLoader resourceLoader , List <ProtocolResolver > protocolResolvers ,
220- List <ResourceFilePathResolver > filePathResolvers ) {
242+ List <FilePathResolver > filePathResolvers ) {
221243 this .resourceLoader = resourceLoader ;
222244 this .protocolResolvers = protocolResolvers ;
223245 this .filePathResolvers = filePathResolvers ;
@@ -239,12 +261,12 @@ public Resource getResource(String location) {
239261 }
240262 }
241263 Resource resource = this .resourceLoader .getResource (location );
242- String fileSystemPath = getFileSystemPath (location , resource );
243- return (fileSystemPath != null ) ? new ApplicationResource (fileSystemPath ) : resource ;
264+ String filePath = getFilePath (location , resource );
265+ return (filePath != null ) ? new ApplicationResource (filePath ) : resource ;
244266 }
245267
246- private String getFileSystemPath (String location , Resource resource ) {
247- for (ResourceFilePathResolver filePathResolver : this .filePathResolvers ) {
268+ private String getFilePath (String location , Resource resource ) {
269+ for (FilePathResolver filePathResolver : this .filePathResolvers ) {
248270 String filePath = filePathResolver .resolveFilePath (location , resource );
249271 if (filePath != null ) {
250272 return filePath ;
0 commit comments