XML configuration support for RFC 5861

This commit adds the XML+XSD configuration part of the RFC 5861
Cache-Control directives added in Spring's `CacheControl`.

Issue: SPR-13841
This commit is contained in:
Brian Clozel
2016-01-07 18:11:06 +01:00
parent 6c282096c6
commit cdda839426
4 changed files with 56 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -242,6 +242,14 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
if (element.hasAttribute("s-maxage")) {
cacheControl = cacheControl.sMaxAge(Long.parseLong(element.getAttribute("s-maxage")), TimeUnit.SECONDS);
}
if (element.hasAttribute("stale-while-revalidate")) {
cacheControl = cacheControl.staleWhileRevalidate(
Long.parseLong(element.getAttribute("stale-while-revalidate")), TimeUnit.SECONDS);
}
if (element.hasAttribute("stale-if-error")) {
cacheControl = cacheControl.staleIfError(
Long.parseLong(element.getAttribute("stale-if-error")), TimeUnit.SECONDS);
}
return cacheControl;
}