|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
|
* Copyright 2002-2015 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. |
|
|
|
|
@ -27,12 +27,11 @@ import org.springframework.web.servlet.resource.PathResourceResolver;
@@ -27,12 +27,11 @@ import org.springframework.web.servlet.resource.PathResourceResolver;
|
|
|
|
|
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Encapsulates information required to create a resource handlers. |
|
|
|
|
* Encapsulates information required to create a resource handler. |
|
|
|
|
* |
|
|
|
|
* @author Rossen Stoyanchev |
|
|
|
|
* @author Keith Donald |
|
|
|
|
* @author Brian Clozel |
|
|
|
|
* |
|
|
|
|
* @since 3.1 |
|
|
|
|
*/ |
|
|
|
|
public class ResourceHandlerRegistration { |
|
|
|
|
@ -67,7 +66,7 @@ public class ResourceHandlerRegistration {
@@ -67,7 +66,7 @@ public class ResourceHandlerRegistration {
|
|
|
|
|
* <p>For example, {{@code "/"}, {@code "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 |
|
|
|
|
* {@code /META-INF/public-web-resources/} directory, with resources in the web application root taking precedence. |
|
|
|
|
* @return the same {@link ResourceHandlerRegistration} instance for chained method invocation |
|
|
|
|
* @return the same {@link ResourceHandlerRegistration} instance, for chained method invocation |
|
|
|
|
*/ |
|
|
|
|
public ResourceHandlerRegistration addResourceLocations(String...resourceLocations) { |
|
|
|
|
for (String location : resourceLocations) { |
|
|
|
|
@ -81,7 +80,7 @@ public class ResourceHandlerRegistration {
@@ -81,7 +80,7 @@ public class ResourceHandlerRegistration {
|
|
|
|
|
* send any cache headers but to rely on last-modified timestamps only. Set to 0 in order to send cache headers |
|
|
|
|
* that prevent caching, or to a positive number of seconds to send cache headers with the given max-age value. |
|
|
|
|
* @param cachePeriod the time to cache resources in seconds |
|
|
|
|
* @return the same {@link ResourceHandlerRegistration} instance for chained method invocation |
|
|
|
|
* @return the same {@link ResourceHandlerRegistration} instance, for chained method invocation |
|
|
|
|
*/ |
|
|
|
|
public ResourceHandlerRegistration setCachePeriod(Integer cachePeriod) { |
|
|
|
|
this.cachePeriod = cachePeriod; |
|
|
|
|
@ -90,16 +89,16 @@ public class ResourceHandlerRegistration {
@@ -90,16 +89,16 @@ public class ResourceHandlerRegistration {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Configure a chain of resource resolvers and transformers to use. This |
|
|
|
|
* can be useful for example to apply a version strategy to resource URLs. |
|
|
|
|
* can be useful, for example, to apply a version strategy to resource URLs. |
|
|
|
|
* |
|
|
|
|
* <p>If this method is not invoked, by default only a simple |
|
|
|
|
* {@link PathResourceResolver} is used in order to match URL paths to |
|
|
|
|
* resources under the configured locations. |
|
|
|
|
* |
|
|
|
|
* @param 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). |
|
|
|
|
* @return the same {@link ResourceHandlerRegistration} instance for chained method invocation |
|
|
|
|
* setting this to "true" is recommended for production (and "false" for |
|
|
|
|
* development, especially when applying a version strategy) |
|
|
|
|
* @return the same {@link ResourceHandlerRegistration} instance, for chained method invocation |
|
|
|
|
* @since 4.1 |
|
|
|
|
*/ |
|
|
|
|
public ResourceChainRegistration resourceChain(boolean cacheResources) { |
|
|
|
|
@ -109,20 +108,21 @@ public class ResourceHandlerRegistration {
@@ -109,20 +108,21 @@ public class ResourceHandlerRegistration {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Configure a chain of resource resolvers and transformers to use. This |
|
|
|
|
* can be useful for example to apply a version strategy to resource URLs. |
|
|
|
|
* can be useful, for example, to apply a version strategy to resource URLs. |
|
|
|
|
* |
|
|
|
|
* <p>If this method is not invoked, by default only a simple |
|
|
|
|
* {@link PathResourceResolver} is used in order to match URL paths to |
|
|
|
|
* resources under the configured locations. |
|
|
|
|
* |
|
|
|
|
* @param 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. |
|
|
|
|
* setting this to "true" is recommended for production (and "false" for |
|
|
|
|
* development, especially when applying a version strategy |
|
|
|
|
* @param cache the cache to use for storing resolved and transformed resources; |
|
|
|
|
* by default a {@link org.springframework.cache.concurrent.ConcurrentMapCache} |
|
|
|
|
* is used. As Resources aren't serializable and can be dependent of the application host, |
|
|
|
|
* one should not use a distributed cache but rather an in-memory cache. |
|
|
|
|
* @return the same {@link ResourceHandlerRegistration} instance for chained method invocation |
|
|
|
|
* by default a {@link org.springframework.cache.concurrent.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. |
|
|
|
|
* @return the same {@link ResourceHandlerRegistration} instance, for chained method invocation |
|
|
|
|
* @since 4.1 |
|
|
|
|
*/ |
|
|
|
|
public ResourceChainRegistration resourceChain(boolean cacheResources, Cache cache) { |
|
|
|
|
|