Commit d43080bfd360c84fbcce15ba059376c6956bceb1
1 parent
7902a74e
Exists in
master
FWK-192: Criação do CacheFilter na extensão REST
Task-Url: https://demoiselle.atlassian.net/browse/FWK-192
Showing
2 changed files
with
11 additions
and
4 deletions
Show diff stats
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/util/CacheFilter.java
... | ... | @@ -56,15 +56,21 @@ public class CacheFilter implements Filter { |
56 | 56 | } |
57 | 57 | |
58 | 58 | @Override |
59 | - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, | |
60 | - ServletException { | |
59 | + public void doFilter(ServletRequest request, ServletResponse response, | |
60 | + FilterChain chain) throws IOException, ServletException { | |
61 | 61 | if (response instanceof HttpServletResponse) { |
62 | - ((HttpServletResponse) response).setHeader("Cache-Control", value); | |
62 | + setCacheControl((HttpServletResponse) response); | |
63 | 63 | } |
64 | 64 | |
65 | 65 | chain.doFilter(request, response); |
66 | 66 | } |
67 | 67 | |
68 | + protected void setCacheControl(HttpServletResponse response) { | |
69 | + if (Strings.isEmpty(response.getHeader("Cache-Control"))) { | |
70 | + response.setHeader("Cache-Control", value); | |
71 | + } | |
72 | + } | |
73 | + | |
68 | 74 | @Override |
69 | 75 | public void destroy() { |
70 | 76 | } | ... | ... |
impl/extension/servlet/src/main/resources/META-INF/web-fragment.xml
... | ... | @@ -35,7 +35,8 @@ |
35 | 35 | 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
36 | 36 | --> |
37 | 37 | <web-fragment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" |
38 | - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd" version="3.0" id="demoiselle-servlet"> | |
38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd" version="3.0" | |
39 | + id="demoiselle-servlet"> | |
39 | 40 | |
40 | 41 | <name>demoiselle_servlet</name> |
41 | 42 | ... | ... |