@@ -153,7 +153,7 @@ public static ResourceLoader get(ResourceLoader resourceLoader) {
153153 * class loader at the time this call is made.
154154 * @param resourceLoader the delegate resource loader
155155 * @param preferFileResolution if file based resolution is preferred when a suitable
156- * {@link ResourceFilePathResolver } support the resource
156+ * {@link FilePathResolver } support the resource
157157 * @return a {@link ResourceLoader} instance
158158 * @since 3.4.1
159159 */
@@ -182,8 +182,8 @@ private static ResourceLoader get(ResourceLoader resourceLoader, SpringFactories
182182 Assert .notNull (resourceLoader , "'resourceLoader' must not be null" );
183183 Assert .notNull (springFactoriesLoader , "'springFactoriesLoader' must not be null" );
184184 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 ();
187187 return new ProtocolResolvingResourceLoader (resourceLoader , protocolResolvers , filePathResolvers );
188188 }
189189
@@ -242,6 +242,28 @@ static ResourceLoader get(ClassLoader classLoader, Path workingDirectory) {
242242
243243 }
244244
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+
245267 /**
246268 * An application {@link Resource}.
247269 */
@@ -272,10 +294,10 @@ private static class ProtocolResolvingResourceLoader implements ResourceLoader {
272294
273295 private final List <ProtocolResolver > protocolResolvers ;
274296
275- private final List <ResourceFilePathResolver > filePathResolvers ;
297+ private final List <FilePathResolver > filePathResolvers ;
276298
277299 ProtocolResolvingResourceLoader (ResourceLoader resourceLoader , List <ProtocolResolver > protocolResolvers ,
278- List <ResourceFilePathResolver > filePathResolvers ) {
300+ List <FilePathResolver > filePathResolvers ) {
279301 this .resourceLoader = resourceLoader ;
280302 this .protocolResolvers = protocolResolvers ;
281303 this .filePathResolvers = filePathResolvers ;
@@ -297,12 +319,12 @@ public Resource getResource(String location) {
297319 }
298320 }
299321 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 ;
302324 }
303325
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 ) {
306328 String filePath = filePathResolver .resolveFilePath (location , resource );
307329 if (filePath != null ) {
308330 return filePath ;
0 commit comments