org.springframework.web.reactive.config

## Class ResourceHandlerRegistration

- java.lang.Object
- - org.springframework.web.reactive.config.ResourceHandlerRegistration

    public class ResourceHandlerRegistration
    extends Object

Assist with creating and configuring a static resources handler.

Since:
  5.0
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
Constructor and Description
`ResourceHandlerRegistration(org.springframework.core.io.ResourceLoader resourceLoader, String... pathPatterns)` Create a `ResourceHandlerRegistration` instance.

### Method Summary

All Methods Instance Methods Concrete Methods
`ResourceHandlerRegistration` `addResourceLocations(String... resourceLocations)` Add one or more resource locations from which to serve static content.
`protected String[]` `getPathPatterns()` Returns the URL path patterns for the resource handler.
`protected ResourceWebHandler` `getRequestHandler()` Returns a `ResourceWebHandler` instance.
`ResourceChainRegistration` `resourceChain(boolean cacheResources)` Configure a chain of resource resolvers and transformers to use.
`ResourceChainRegistration` `resourceChain(boolean cacheResources, org.springframework.cache.Cache cache)` Configure a chain of resource resolvers and transformers to use.
`ResourceHandlerRegistration` `setCacheControl(org.springframework.http.CacheControl cacheControl)` Specify the `CacheControl` which should be used by the resource handler.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ResourceHandlerRegistration

    public ResourceHandlerRegistration(org.springframework.core.io.ResourceLoader resourceLoader,
                                       String... pathPatterns)

Create a `ResourceHandlerRegistration` instance.

Parameters:
  `resourceLoader` - a resource loader for turning a String location into a `Resource`
  `pathPatterns` - one or more resource URL path patterns

### Method Detail

#### addResourceLocations

    public ResourceHandlerRegistration addResourceLocations(String... resourceLocations)

Add one or more resource locations from which to serve static content. Each location must point to a valid directory. Multiple locations may be specified as a comma-separated list, and the locations will be checked for a given resource in the order specified.

For example, {`"/"`, `"classpath:/META-INF/public-web-resources/"`} allows resources to be served both from the web application root and from any JAR on the classpath that contains a `/META-INF/public-web-resources/` directory, with resources in the web application root taking precedence.

Returns:
  the same `ResourceHandlerRegistration` instance, for chained method invocation

#### setCacheControl

    public ResourceHandlerRegistration setCacheControl(org.springframework.http.CacheControl cacheControl)

Specify the `CacheControl` which should be used by the resource handler.

Parameters:
  `cacheControl` - the CacheControl configuration to use
Returns:
  the same `ResourceHandlerRegistration` instance, for chained method invocation

#### resourceChain

    public ResourceChainRegistration resourceChain(boolean cacheResources)

Configure a chain of resource resolvers and transformers to use. This can be useful, for example, to apply a version strategy to resource URLs.

If this method is not invoked, by default only a simple `PathResourceResolver` is used in order to match URL paths to resources under the configured locations.

Parameters:
  `cacheResources` - whether to cache the result of resource resolution; setting this to "true" is recommended for production (and "false" for development, especially when applying a version strategy)
Returns:
  the same `ResourceHandlerRegistration` instance, for chained method invocation

#### resourceChain

    public ResourceChainRegistration resourceChain(boolean cacheResources,
                                                   org.springframework.cache.Cache cache)

Configure a chain of resource resolvers and transformers to use. This can be useful, for example, to apply a version strategy to resource URLs.

If this method is not invoked, by default only a simple `PathResourceResolver` is used in order to match URL paths to resources under the configured locations.

Parameters:
  `cacheResources` - whether to cache the result of resource resolution; setting this to "true" is recommended for production (and "false" for development, especially when applying a version strategy
  `cache` - the cache to use for storing resolved and transformed resources; by default a `ConcurrentMapCache` is used. Since Resources aren't serializable and can be dependent on the application host, one should not use a distributed cache but rather an in-memory cache.
Returns:
  the same `ResourceHandlerRegistration` instance, for chained method invocation

#### getPathPatterns

    protected String[] getPathPatterns()

Returns the URL path patterns for the resource handler.

#### getRequestHandler

    protected ResourceWebHandler getRequestHandler()

Returns a `ResourceWebHandler` instance.