@@ -40,7 +40,7 @@ following listing provides an overview of the `Resource` interface. See the
40
40
{api-spring-framework}/core/io/Resource.html[`Resource`] javadoc for further details.
41
41
42
42
43
- [source,java,indent=0,subs="verbatim,quotes",role="primary" ]
43
+ [source,java,indent=0,subs="verbatim,quotes"]
44
44
.Java
45
45
----
46
46
public interface Resource extends InputStreamSource {
@@ -70,67 +70,21 @@ following listing provides an overview of the `Resource` interface. See the
70
70
String getFilename();
71
71
72
72
String getDescription();
73
-
74
- }
75
- ----
76
- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
77
- .Kotlin
78
- ----
79
- interface Resource : InputStreamSource {
80
-
81
- fun exists(): Boolean
82
-
83
- fun isReadable(): Boolean
84
-
85
- fun isOpen(): Boolean
86
-
87
- fun isFile(): Boolean
88
-
89
- fun getURL(): URL
90
-
91
- @Throws(IOException::class)
92
- fun getURI(): URI
93
-
94
- val file: File
95
-
96
- @Throws(IOException::class)
97
- fun readableChannel(): ReadableByteChannel
98
-
99
- @Throws(IOException::class)
100
- fun contentLength(): long
101
-
102
- @Throws(IOException::class)
103
- fun lastModified(): long
104
-
105
- @Throws(IOException::class)
106
- fun createRelative(relativePath: String): Resource
107
-
108
- val filename: String
109
-
110
- val description: String
111
73
}
112
74
----
113
75
114
76
As the definition of the `Resource` interface shows, it extends the `InputStreamSource`
115
77
interface. The following listing shows the definition of the `InputStreamSource`
116
78
interface:
117
79
118
- [source,java,indent=0,subs="verbatim,quotes",role="primary" ]
80
+ [source,java,indent=0,subs="verbatim,quotes"]
119
81
.Java
120
82
----
121
83
public interface InputStreamSource {
122
84
123
85
InputStream getInputStream() throws IOException;
124
86
}
125
87
----
126
- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
127
- .Kotlin
128
- ----
129
- interface InputStreamSource {
130
-
131
- val inputStream: InputStream
132
- }
133
- ----
134
88
135
89
Some of the most important methods from the `Resource` interface are:
136
90
@@ -303,7 +257,7 @@ The `ResourceLoader` interface is meant to be implemented by objects that can re
303
257
(that is, load) `Resource` instances. The following listing shows the `ResourceLoader`
304
258
interface definition:
305
259
306
- [source,java,indent=0,subs="verbatim,quotes",role="primary" ]
260
+ [source,java,indent=0,subs="verbatim,quotes"]
307
261
.Java
308
262
----
309
263
public interface ResourceLoader {
@@ -313,16 +267,6 @@ interface definition:
313
267
ClassLoader getClassLoader();
314
268
}
315
269
----
316
- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
317
- .Kotlin
318
- ----
319
- interface ResourceLoader {
320
-
321
- fun getResource(location: String): Resource
322
-
323
- fun getClassLoader(): ClassLoader
324
- }
325
- ----
326
270
327
271
All application contexts implement the `ResourceLoader` interface. Therefore, all
328
272
application contexts may be used to obtain `Resource` instances.
@@ -426,28 +370,14 @@ The `ResourcePatternResolver` interface is an extension to the `ResourceLoader`
426
370
which defines a strategy for resolving a location pattern (for example, an Ant-style path
427
371
pattern) into `Resource` objects.
428
372
429
- [source,java,indent=0,subs="verbatim,quotes",role="primary" ]
373
+ [source,java,indent=0,subs="verbatim,quotes"]
430
374
.Java
431
375
----
432
376
public interface ResourcePatternResolver extends ResourceLoader {
433
377
434
378
String CLASSPATH_ALL_URL_PREFIX = "classpath*:";
435
379
436
380
Resource[] getResources(String locationPattern) throws IOException;
437
-
438
- }
439
- ----
440
- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
441
- .Kotlin
442
- ----
443
- interface ResourcePatternResolver: ResourceLoader {
444
-
445
- @JvmField
446
- val CLASSPATH_ALL_URL_PREFIX: String = "classpath*:"
447
-
448
- @Throws(IOException::class)
449
- fun getResources(locationPattern: String): Resource[]
450
-
451
381
}
452
382
----
453
383
@@ -492,22 +422,14 @@ The `ResourceLoaderAware` interface is a special callback interface which identi
492
422
components that expect to be provided a `ResourceLoader` reference. The following listing
493
423
shows the definition of the `ResourceLoaderAware` interface:
494
424
495
- [source,java,indent=0,subs="verbatim,quotes",role="primary" ]
425
+ [source,java,indent=0,subs="verbatim,quotes"]
496
426
.Java
497
427
----
498
428
public interface ResourceLoaderAware {
499
429
500
430
void setResourceLoader(ResourceLoader resourceLoader);
501
431
}
502
432
----
503
- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
504
- .Kotlin
505
- ----
506
- interface ResourceLoaderAware {
507
-
508
- fun setResourceLoader(resourceLoader: ResourceLoader)
509
- }
510
- ----
511
433
512
434
When a class implements `ResourceLoaderAware` and is deployed into an application context
513
435
(as a Spring-managed bean), it is recognized as `ResourceLoaderAware` by the application
0 commit comments