mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Polishing
This commit is contained in:
@@ -162,7 +162,7 @@ public interface Resource extends InputStreamSource {
|
||||
* <p>The given consumer will be invoked a single time by default - but may
|
||||
* also be invoked multiple times in case of a multi-content resource handle,
|
||||
* for example returned from a
|
||||
* {@link ResourceLoader#getResource getResource("classpath*:..."} call.
|
||||
* {@link ResourceLoader#getResource getResource("classpath*:...")} call.
|
||||
* While {@link #getInputStream()} returns a merged sequence of content
|
||||
* in such a case, this method performs one callback per file content.
|
||||
* @param consumer a consumer for each InputStream
|
||||
|
||||
@@ -43,14 +43,14 @@ import org.springframework.util.ResourceUtils;
|
||||
public interface ResourceLoader {
|
||||
|
||||
/**
|
||||
* Pseudo URL prefix for loading from the class path: "classpath:".
|
||||
* This retrieves the "nearest" matching resource in the classpath.
|
||||
* Pseudo URL prefix for loading from the class path: {@value}.
|
||||
* <p>This retrieves the "nearest" matching resource in the classpath.
|
||||
* @see ClassLoader#getResource
|
||||
*/
|
||||
String CLASSPATH_URL_PREFIX = ResourceUtils.CLASSPATH_URL_PREFIX;
|
||||
|
||||
/**
|
||||
* Pseudo URL prefix for all matching resources from the class path: {@code "classpath*:"}.
|
||||
* Pseudo URL prefix for all matching resources from the class path: {@value}.
|
||||
* <p>This differs from the common {@link #CLASSPATH_URL_PREFIX "classpath:"} prefix
|
||||
* in that it retrieves all matching resources for a given path. For example, to
|
||||
* locate all "messages.properties" files in the root of all deployed JAR files
|
||||
@@ -72,7 +72,7 @@ public interface ResourceLoader {
|
||||
* Return a {@code Resource} handle for the specified resource location.
|
||||
* <p>The handle should always be a reusable resource descriptor,
|
||||
* allowing for multiple {@link Resource#getInputStream()} calls.
|
||||
* <p><ul>
|
||||
* <ul>
|
||||
* <li>Must support fully qualified URLs, for example, "file:C:/test.properties".
|
||||
* <li>Must support classpath pseudo-URLs, for example, "classpath:test.properties".
|
||||
* (Exposing the "nearest" resource in the classpath; see {@link ClassLoader#getResource}.)
|
||||
@@ -91,6 +91,7 @@ public interface ResourceLoader {
|
||||
* @param location the resource location
|
||||
* @return a corresponding {@code Resource} handle (never {@code null})
|
||||
* @see #CLASSPATH_URL_PREFIX
|
||||
* @see #CLASSPATH_ALL_URL_PREFIX
|
||||
* @see Resource#exists()
|
||||
* @see Resource#consumeContent
|
||||
*/
|
||||
|
||||
@@ -168,7 +168,7 @@ public class EncodedResource implements InputStreamSource {
|
||||
* <p>The given consumer will be invoked a single time by default - but may
|
||||
* also be invoked multiple times in case of a multi-content resource handle,
|
||||
* for example returned from a
|
||||
* {@link ResourceLoader#getResource getResource("classpath*:..."} call.
|
||||
* {@link ResourceLoader#getResource getResource("classpath*:...")} call.
|
||||
* While {@link #getReader()} returns a merged sequence of content
|
||||
* in such a case, this method performs one callback per file content.
|
||||
* @param consumer a consumer for each Reader
|
||||
|
||||
+6
-3
@@ -56,6 +56,7 @@ import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.core.testfixture.ide.IdeUtils;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
@@ -112,9 +113,11 @@ class PathMatchingResourcePatternResolverTests {
|
||||
long length1 = 0;
|
||||
Resource[] resources1 = resolver.getResources("classpath*:META-INF/MANIFEST.MF");
|
||||
for (Resource resource : resources1) {
|
||||
assertThat(resource.exists()).isTrue();
|
||||
assertThat(resource.isReadable()).isTrue();
|
||||
assertThat(resource.isFile()).isFalse();
|
||||
assertThat(resource.exists()).as("%s exists", resource).isTrue();
|
||||
assertThat(resource.isReadable()).as("%s is readable", resource).isTrue();
|
||||
if (!IdeUtils.runningInEclipse()) {
|
||||
assertThat(resource.isFile()).as("%s is a file", resource).isFalse();
|
||||
}
|
||||
length1 += resource.contentLength();
|
||||
resource.consumeContent(inputStream ->
|
||||
content1.append(FileCopyUtils.copyToString(new InputStreamReader(inputStream))));
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.web.cors.PreFlightRequestHandler;
|
||||
* Servlet Filter that handles pre-flight requests through a
|
||||
* {@link PreFlightRequestHandler} and bypasses the rest of the chain.
|
||||
*
|
||||
* <p>The {@code @EnableWebMvc} config declares bean of type
|
||||
* <p>The {@code @EnableWebMvc} config declares a bean of type
|
||||
* {@code PreFlightRequestHandler}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -68,4 +68,5 @@ public class PreFlightRequestFilter extends OncePerRequestFilter {
|
||||
throw new ServletException("Pre-flight request handling failed: " + ex, ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user