From c26087e848be749e493b2e29a1a99689a835c716 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 15 Feb 2021 21:04:37 +0100 Subject: [PATCH] Document PathResource as a built-in Resource in the reference manual See gh-26447 --- src/docs/asciidoc/core/core-resources.adoc | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/docs/asciidoc/core/core-resources.adoc b/src/docs/asciidoc/core/core-resources.adoc index 30748a9607f..6dae0e5953c 100644 --- a/src/docs/asciidoc/core/core-resources.adoc +++ b/src/docs/asciidoc/core/core-resources.adoc @@ -150,6 +150,10 @@ Other methods let you obtain an actual `URL` or `File` object representing the resource (if the underlying implementation is compatible and supports that functionality). +Some implementations of the `Resource` interface also implement the extended +{api-spring-framework}/core/io/WritableResource.html[`WritableResource`] interface +for a resource that supports writing to it. + Spring itself uses the `Resource` abstraction extensively, as an argument type in many method signatures when a resource is needed. Other methods in some Spring APIs (such as the constructors to various `ApplicationContext` implementations) take a @@ -174,11 +178,13 @@ work. [[resources-implementations]] == Built-in Resource Implementations -Spring includes the following `Resource` implementations: +Spring includes several built-in `Resource` implementations, including but not limited to +the following: * <> * <> * <> +* <> * <> * <> * <> @@ -229,8 +235,21 @@ creates a `ClassPathResource` in that case. [[resources-implementations-filesystemresource]] === `FileSystemResource` -This is a `Resource` implementation for `java.io.File` and `java.nio.file.Path` handles. -It supports resolution as a `File` and as a `URL`. +This is a `Resource` implementation for `java.io.File` handles. It also supports +`java.nio.file.Path` handles, applying Spring's standard String-based path +transformations but performing all operations via the `java.nio.file.Files` API. For pure +`java.nio.path.Path` based support use a `PathResource` instead. `FileSystemResource` +supports resolution as a `File` and as a `URL`. + + +[[resources-implementations-pathresource]] +=== `PathResource` + +This is a `Resource` implementation for `java.nio.file.Path` handles, performing all +operations and transformations via the `Path` API. It supports resolution as a `File` and +as a `URL` and also implements the extended `WritableResource` interface. `PathResource` +is effectively a pure `java.nio.path.Path` based alternative to `FileSystemResource` with +different `createRelative` behavior.