@@ -153,7 +153,7 @@ public static ResourceLoader get(ResourceLoader resourceLoader) {
153
153
* class loader at the time this call is made.
154
154
* @param resourceLoader the delegate resource loader
155
155
* @param preferFileResolution if file based resolution is preferred when a suitable
156
- * {@link ResourceFilePathResolver } support the resource
156
+ * {@link FilePathResolver } support the resource
157
157
* @return a {@link ResourceLoader} instance
158
158
* @since 3.4.1
159
159
*/
@@ -182,8 +182,8 @@ private static ResourceLoader get(ResourceLoader resourceLoader, SpringFactories
182
182
Assert .notNull (resourceLoader , "'resourceLoader' must not be null" );
183
183
Assert .notNull (springFactoriesLoader , "'springFactoriesLoader' must not be null" );
184
184
List <ProtocolResolver > protocolResolvers = springFactoriesLoader .load (ProtocolResolver .class );
185
- List <ResourceFilePathResolver > filePathResolvers = (preferFileResolution )
186
- ? springFactoriesLoader .load (ResourceFilePathResolver .class ) : Collections .emptyList ();
185
+ List <FilePathResolver > filePathResolvers = (preferFileResolution )
186
+ ? springFactoriesLoader .load (FilePathResolver .class ) : Collections .emptyList ();
187
187
return new ProtocolResolvingResourceLoader (resourceLoader , protocolResolvers , filePathResolvers );
188
188
}
189
189
@@ -242,6 +242,28 @@ static ResourceLoader get(ClassLoader classLoader, Path workingDirectory) {
242
242
243
243
}
244
244
245
+ /**
246
+ * Strategy interface registered in {@code spring.factories} and used by
247
+ * {@link ApplicationResourceLoader} to determine the file path of loaded resource
248
+ * when it can also be represented as a {@link FileSystemResource}.
249
+ *
250
+ * @author Phillip Webb
251
+ * @since 3.4.5
252
+ */
253
+ public interface FilePathResolver {
254
+
255
+ /**
256
+ * Return the {@code path} of the given resource if it can also be represented as
257
+ * a {@link FileSystemResource}.
258
+ * @param location the location used to create the resource
259
+ * @param resource the resource to check
260
+ * @return the file path of the resource or {@code null} if the it is not possible
261
+ * to represent the resource as a {@link FileSystemResource}.
262
+ */
263
+ String resolveFilePath (String location , Resource resource );
264
+
265
+ }
266
+
245
267
/**
246
268
* An application {@link Resource}.
247
269
*/
@@ -272,10 +294,10 @@ private static class ProtocolResolvingResourceLoader implements ResourceLoader {
272
294
273
295
private final List <ProtocolResolver > protocolResolvers ;
274
296
275
- private final List <ResourceFilePathResolver > filePathResolvers ;
297
+ private final List <FilePathResolver > filePathResolvers ;
276
298
277
299
ProtocolResolvingResourceLoader (ResourceLoader resourceLoader , List <ProtocolResolver > protocolResolvers ,
278
- List <ResourceFilePathResolver > filePathResolvers ) {
300
+ List <FilePathResolver > filePathResolvers ) {
279
301
this .resourceLoader = resourceLoader ;
280
302
this .protocolResolvers = protocolResolvers ;
281
303
this .filePathResolvers = filePathResolvers ;
@@ -297,12 +319,12 @@ public Resource getResource(String location) {
297
319
}
298
320
}
299
321
Resource resource = this .resourceLoader .getResource (location );
300
- String fileSystemPath = getFileSystemPath (location , resource );
301
- return (fileSystemPath != null ) ? new ApplicationResource (fileSystemPath ) : resource ;
322
+ String filePath = getFilePath (location , resource );
323
+ return (filePath != null ) ? new ApplicationResource (filePath ) : resource ;
302
324
}
303
325
304
- private String getFileSystemPath (String location , Resource resource ) {
305
- for (ResourceFilePathResolver filePathResolver : this .filePathResolvers ) {
326
+ private String getFilePath (String location , Resource resource ) {
327
+ for (FilePathResolver filePathResolver : this .filePathResolvers ) {
306
328
String filePath = filePathResolver .resolveFilePath (location , resource );
307
329
if (filePath != null ) {
308
330
return filePath ;
0 commit comments