@@ -131,7 +131,7 @@ public static ResourceLoader get(ResourceLoader resourceLoader) {
131
131
* class loader at the time this call is made.
132
132
* @param resourceLoader the delegate resource loader
133
133
* @param preferFileResolution if file based resolution is preferred when a suitable
134
- * {@link ResourceFilePathResolver } support the resource
134
+ * {@link FilePathResolver } support the resource
135
135
* @return a {@link ResourceLoader} instance
136
136
* @since 3.4.1
137
137
*/
@@ -160,8 +160,8 @@ private static ResourceLoader get(ResourceLoader resourceLoader, SpringFactories
160
160
Assert .notNull (resourceLoader , "'resourceLoader' must not be null" );
161
161
Assert .notNull (springFactoriesLoader , "'springFactoriesLoader' must not be null" );
162
162
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 ();
165
165
return new ProtocolResolvingResourceLoader (resourceLoader , protocolResolvers , filePathResolvers );
166
166
}
167
167
@@ -188,6 +188,28 @@ static ResourceLoader get(ClassLoader classLoader) {
188
188
189
189
}
190
190
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
+
191
213
/**
192
214
* An application {@link Resource}.
193
215
*/
@@ -214,10 +236,10 @@ private static class ProtocolResolvingResourceLoader implements ResourceLoader {
214
236
215
237
private final List <ProtocolResolver > protocolResolvers ;
216
238
217
- private final List <ResourceFilePathResolver > filePathResolvers ;
239
+ private final List <FilePathResolver > filePathResolvers ;
218
240
219
241
ProtocolResolvingResourceLoader (ResourceLoader resourceLoader , List <ProtocolResolver > protocolResolvers ,
220
- List <ResourceFilePathResolver > filePathResolvers ) {
242
+ List <FilePathResolver > filePathResolvers ) {
221
243
this .resourceLoader = resourceLoader ;
222
244
this .protocolResolvers = protocolResolvers ;
223
245
this .filePathResolvers = filePathResolvers ;
@@ -239,12 +261,12 @@ public Resource getResource(String location) {
239
261
}
240
262
}
241
263
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 ;
244
266
}
245
267
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 ) {
248
270
String filePath = filePathResolver .resolveFilePath (location , resource );
249
271
if (filePath != null ) {
250
272
return filePath ;
0 commit comments