diff --git a/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java b/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java index 4e8568a20c8..878d33108ec 100644 --- a/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java +++ b/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,10 @@ import org.springframework.core.io.ResourceLoader; * the {@link org.springframework.context.ApplicationContextAware} interface. * *
Note that {@link org.springframework.core.io.Resource} dependencies can also - * be exposed as bean properties of type {@code Resource}, populated via Strings - * with automatic type conversion by the bean factory. This removes the need for - * implementing any callback interface just for the purpose of accessing a - * specific file resource. + * be exposed as bean properties of type {@code Resource} or {@code Resource[]}, + * populated via Strings with automatic type conversion by the bean factory. This + * removes the need for implementing any callback interface just for the purpose + * of accessing specific file resources. * *
You typically need a {@link ResourceLoader} when your application object has to * access a variety of file resources whose names are calculated. A good strategy is @@ -48,7 +48,7 @@ import org.springframework.core.io.ResourceLoader; * default; see also the {@code ResourcePatternUtils.getResourcePatternResolver} method. * *
As an alternative to a {@code ResourcePatternResolver} dependency, consider - * exposing bean properties of type {@code Resource} array, populated via pattern + * exposing bean properties of type {@code Resource[]} array, populated via pattern * Strings with automatic type conversion by the bean factory at binding time. * * @author Juergen Hoeller diff --git a/spring-core/src/main/java/org/springframework/core/io/ResourceLoader.java b/spring-core/src/main/java/org/springframework/core/io/ResourceLoader.java index 9a19fda7dd6..f66befdd547 100644 --- a/spring-core/src/main/java/org/springframework/core/io/ResourceLoader.java +++ b/spring-core/src/main/java/org/springframework/core/io/ResourceLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,15 +20,15 @@ import org.springframework.lang.Nullable; import org.springframework.util.ResourceUtils; /** - * Strategy interface for loading resources (e.. class path or file system + * Strategy interface for loading resources (e.g., class path or file system * resources). An {@link org.springframework.context.ApplicationContext} - * is required to provide this functionality, plus extended + * is required to provide this functionality plus extended * {@link org.springframework.core.io.support.ResourcePatternResolver} support. * *
{@link DefaultResourceLoader} is a standalone implementation that is - * usable outside an ApplicationContext, also used by {@link ResourceEditor}. + * usable outside an ApplicationContext and is also used by {@link ResourceEditor}. * - *
Bean properties of type Resource and Resource array can be populated + *
Bean properties of type {@code Resource} and {@code Resource[]} can be populated * from Strings when running in an ApplicationContext, using the particular * context's resource loading strategy. * @@ -46,7 +46,7 @@ public interface ResourceLoader { /** - * Return a Resource handle for the specified resource location. + * Return a {@code Resource} handle for the specified resource location. *
The handle should always be a reusable resource descriptor, * allowing for multiple {@link Resource#getInputStream()} calls. *
Note that a Resource handle does not imply an existing resource; + *
Note that a {@code Resource} handle does not imply an existing resource; * you need to invoke {@link Resource#exists} to check for existence. * @param location the resource location - * @return a corresponding Resource handle (never {@code null}) + * @return a corresponding {@code Resource} handle (never {@code null}) * @see #CLASSPATH_URL_PREFIX * @see Resource#exists() * @see Resource#getInputStream() @@ -67,12 +67,12 @@ public interface ResourceLoader { Resource getResource(String location); /** - * Expose the ClassLoader used by this ResourceLoader. - *
Clients which need to access the ClassLoader directly can do so - * in a uniform manner with the ResourceLoader, rather than relying - * on the thread context ClassLoader. - * @return the ClassLoader - * (only {@code null} if even the system ClassLoader isn't accessible) + * Expose the {@link ClassLoader} used by this {@code ResourceLoader}. + *
Clients which need to access the {@code ClassLoader} directly can do so + * in a uniform manner with the {@code ResourceLoader}, rather than relying + * on the thread context {@code ClassLoader}. + * @return the {@code ClassLoader} + * (only {@code null} if even the system {@code ClassLoader} isn't accessible) * @see org.springframework.util.ClassUtils#getDefaultClassLoader() * @see org.springframework.util.ClassUtils#forName(String, ClassLoader) */ diff --git a/spring-core/src/main/java/org/springframework/core/io/support/ResourcePatternResolver.java b/spring-core/src/main/java/org/springframework/core/io/support/ResourcePatternResolver.java index b079382ca84..901323fae0f 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/ResourcePatternResolver.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/ResourcePatternResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,17 +23,18 @@ import org.springframework.core.io.ResourceLoader; /** * Strategy interface for resolving a location pattern (for example, - * an Ant-style path pattern) into Resource objects. + * an Ant-style path pattern) into {@link Resource} objects. * *
This is an extension to the {@link org.springframework.core.io.ResourceLoader} - * interface. A passed-in ResourceLoader (for example, an + * interface. A passed-in {@code ResourceLoader} (for example, an * {@link org.springframework.context.ApplicationContext} passed in via * {@link org.springframework.context.ResourceLoaderAware} when running in a context) * can be checked whether it implements this extended interface too. * *
{@link PathMatchingResourcePatternResolver} is a standalone implementation - * that is usable outside an ApplicationContext, also used by - * {@link ResourceArrayPropertyEditor} for populating Resource array bean properties. + * that is usable outside an {@code ApplicationContext}, also used by + * {@link ResourceArrayPropertyEditor} for populating {@code Resource} array bean + * properties. * *
Can be used with any sort of location pattern (e.g. "/WEB-INF/*-context.xml"): * Input patterns have to match the strategy implementation. This interface just @@ -42,7 +43,8 @@ import org.springframework.core.io.ResourceLoader; *
This interface also suggests a new resource prefix "classpath*:" for all * matching resources from the class path. Note that the resource location is * expected to be a path without placeholders in this case (e.g. "/beans.xml"); - * JAR files or classes directories can contain multiple files of the same name. + * JAR files or different directories in the class path can contain multiple files + * of the same name. * * @author Juergen Hoeller * @since 1.0.2 @@ -55,7 +57,7 @@ public interface ResourcePatternResolver extends ResourceLoader { /** * Pseudo URL prefix for all matching resources from the class path: "classpath*:" - * This differs from ResourceLoader's classpath URL prefix in that it + *
This differs from ResourceLoader's classpath URL prefix in that it * retrieves all matching resources for a given name (e.g. "/beans.xml"), * for example in the root of all deployed JAR files. * @see org.springframework.core.io.ResourceLoader#CLASSPATH_URL_PREFIX @@ -63,12 +65,12 @@ public interface ResourcePatternResolver extends ResourceLoader { String CLASSPATH_ALL_URL_PREFIX = "classpath*:"; /** - * Resolve the given location pattern into Resource objects. + * Resolve the given location pattern into {@code Resource} objects. *
Overlapping resource entries that point to the same physical * resource should be avoided, as far as possible. The result should * have set semantics. * @param locationPattern the location pattern to resolve - * @return the corresponding Resource objects + * @return the corresponding {@code Resource} objects * @throws IOException in case of I/O errors */ Resource[] getResources(String locationPattern) throws IOException;