Skip to content

Commit 48bb5ec

Browse files
committed
2 parents 382cb9c + 8a18999 commit 48bb5ec

File tree

5 files changed

+227
-92
lines changed

5 files changed

+227
-92
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
= J2EE Cache Filter =
33
=====================
44

5+
== 1.2 ==
6+
* Changed the default package to com.samaxes.filter.
7+
* Updated the distribution repositories to Sonatype Nexus.
8+
59
== 1.1.0 ==
610
* Use response.setDateHeader() instead of response.setHeader() to set "Expires" HTTP cache header.
711
* Compiled against JDK 1.5 instead of JDK 1.6.
File renamed without changes.

trunk/pom.xml renamed to pom.xml

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<project
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
36
<modelVersion>4.0.0</modelVersion>
47

5-
<groupId>com.samaxes.cachefilter</groupId>
8+
<groupId>com.samaxes.filter</groupId>
69
<artifactId>cachefilter</artifactId>
710
<version>1.2</version>
811
<packaging>jar</packaging>
912

1013
<name>J2EE Cache Filter</name>
1114
<description>J2EE Cache Filter is a Servlet Filter that allows you to set HTTP headers in order to enable browser caching.</description>
1215
<url>http://code.google.com/p/cache-filter/</url>
13-
<inceptionYear>2010</inceptionYear>
16+
<inceptionYear>2007</inceptionYear>
17+
<organization>
18+
<name>samaxes</name>
19+
<url>http://www.samaxes.com/</url>
20+
</organization>
1421
<licenses>
1522
<license>
1623
<name>The Apache Software License, Version 2.0</name>
@@ -37,17 +44,21 @@
3744
<url>http://code.google.com/p/cache-filter/issues/list</url>
3845
</issueManagement>
3946
<scm>
40-
<connection>scm:svn:http://cache-filter.googlecode.com/svn/tags/cachefilter-1.2</connection>
41-
<developerConnection>scm:svn:https://cache-filter.googlecode.com/svn/tags/cachefilter-1.2</developerConnection>
42-
<url>http://cache-filter.googlecode.com/svn/tags/cachefilter-1.2</url>
47+
<connection>scm:svn:http://cache-filter.googlecode.com/svn/trunk</connection>
48+
<developerConnection>scm:svn:https://cache-filter.googlecode.com/svn/trunk</developerConnection>
49+
<url>http://cache-filter.googlecode.com/svn/trunk</url>
4350
</scm>
4451

52+
<prerequisites>
53+
<maven>[2.1.0,)</maven>
54+
</prerequisites>
55+
4556
<build>
4657
<plugins>
4758
<plugin>
4859
<groupId>org.apache.maven.plugins</groupId>
4960
<artifactId>maven-compiler-plugin</artifactId>
50-
<version>2.1</version>
61+
<version>2.3</version>
5162
<configuration>
5263
<source>1.5</source>
5364
<target>1.5</target>
@@ -79,8 +90,13 @@
7990
</plugin>
8091
<plugin>
8192
<groupId>org.apache.maven.plugins</groupId>
82-
<artifactId>maven-release-plugin</artifactId>
83-
<version>2.0-beta-9</version>
93+
<artifactId>maven-gpg-plugin</artifactId>
94+
<version>1.0</version>
95+
</plugin>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-site-plugin</artifactId>
99+
<version>2.1</version>
84100
</plugin>
85101
</plugins>
86102
</build>
@@ -106,4 +122,35 @@
106122
<scope>provided</scope>
107123
</dependency>
108124
</dependencies>
125+
126+
<reporting>
127+
<plugins>
128+
<plugin>
129+
<groupId>org.apache.maven.plugins</groupId>
130+
<artifactId>maven-javadoc-plugin</artifactId>
131+
<version>2.6.1</version>
132+
<configuration>
133+
<charset>UTF-8</charset>
134+
<encoding>UTF-8</encoding>
135+
<docencoding>UTF-8</docencoding>
136+
<source>1.5</source>
137+
<linksource>true</linksource>
138+
<quiet>true</quiet>
139+
<links>
140+
<link>http://java.sun.com/javase/6/docs/api/</link>
141+
</links>
142+
</configuration>
143+
</plugin>
144+
<plugin>
145+
<groupId>org.apache.maven.plugins</groupId>
146+
<artifactId>maven-jxr-plugin</artifactId>
147+
<version>2.1</version>
148+
<configuration>
149+
<inputEncoding>UTF-8</inputEncoding>
150+
<outputEncoding>UTF-8</outputEncoding>
151+
<javadocDir>target/site/apidocs</javadocDir>
152+
</configuration>
153+
</plugin>
154+
</plugins>
155+
</reporting>
109156
</project>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* $Id$
3+
*
4+
* Copyright 2008 samaxes.com
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.samaxes.cachefilter.presentation;
19+
20+
import java.io.IOException;
21+
22+
import javax.servlet.Filter;
23+
import javax.servlet.FilterChain;
24+
import javax.servlet.FilterConfig;
25+
import javax.servlet.ServletException;
26+
import javax.servlet.ServletRequest;
27+
import javax.servlet.ServletResponse;
28+
import javax.servlet.http.HttpServletResponse;
29+
30+
/**
31+
* Filter responsible for browser caching.
32+
*
33+
* @author : Samuel Santos
34+
* @version : $Revision: 25 $
35+
* @deprecated Please update to the new {@link com.samaxes.filter.CacheFilter CacheFilter} instead.
36+
*/
37+
public class CacheFilter implements Filter {
38+
39+
private FilterConfig filterConfig;
40+
41+
/**
42+
* Place this filter into service.
43+
*
44+
* @param filterConfig {@link FilterConfig}
45+
*/
46+
public void init(FilterConfig filterConfig) throws ServletException {
47+
this.filterConfig = filterConfig;
48+
}
49+
50+
/**
51+
* Take this filter out of service.
52+
*/
53+
public void destroy() {
54+
this.filterConfig = null;
55+
}
56+
57+
/**
58+
* Sets cache headers directives.
59+
*
60+
* @param servletRequest {@link ServletRequest}
61+
* @param servletResponse {@link ServletResponse}
62+
* @param filterChain {@link FilterChain}
63+
* @throws IOException {@link FilterChain}
64+
* @throws ServletException {@link ServletException}
65+
*/
66+
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
67+
throws IOException, ServletException {
68+
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
69+
String privacy = filterConfig.getInitParameter("privacy");
70+
String expirationTime = filterConfig.getInitParameter("expirationTime");
71+
72+
if (httpServletResponse != null && privacy != null && !"".equals(privacy) && expirationTime != null
73+
&& !"".equals(expirationTime)) {
74+
long seconds = Long.valueOf(expirationTime);
75+
76+
// set the provided HTTP response parameters
77+
httpServletResponse.setHeader("Cache-Control", privacy + ", max-age=" + seconds + ", must-revalidate");
78+
httpServletResponse.setDateHeader("Expires", System.currentTimeMillis() + seconds * 1000L);
79+
}
80+
81+
// pass the request/response on
82+
filterChain.doFilter(servletRequest, servletResponse);
83+
}
84+
}

trunk/src/main/java/com/samaxes/cachefilter/presentation/CacheFilter.java renamed to src/main/java/com/samaxes/filter/CacheFilter.java

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,83 @@
1-
/*
2-
* $Id$
3-
*
4-
* Copyright 2008 samaxes.com
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
18-
package com.samaxes.cachefilter.presentation;
19-
20-
import java.io.IOException;
21-
22-
import javax.servlet.Filter;
23-
import javax.servlet.FilterChain;
24-
import javax.servlet.FilterConfig;
25-
import javax.servlet.ServletException;
26-
import javax.servlet.ServletRequest;
27-
import javax.servlet.ServletResponse;
28-
import javax.servlet.http.HttpServletResponse;
29-
30-
/**
31-
* Filter responsible for browser caching.
32-
*
33-
* @author : Samuel Santos
34-
* @version : $Revision: 25 $
35-
*/
36-
public class CacheFilter implements Filter {
37-
38-
private FilterConfig filterConfig;
39-
40-
/**
41-
* Place this filter into service.
42-
*
43-
* @param filterConfig {@link FilterConfig}
44-
*/
45-
public void init(FilterConfig filterConfig) throws ServletException {
46-
this.filterConfig = filterConfig;
47-
}
48-
49-
/**
50-
* Take this filter out of service.
51-
*/
52-
public void destroy() {
53-
this.filterConfig = null;
54-
}
55-
56-
/**
57-
* Sets cache headers directives.
58-
*
59-
* @param servletRequest {@link ServletRequest}
60-
* @param servletResponse {@link ServletResponse}
61-
* @param filterChain {@link FilterChain}
62-
* @throws IOException {@link FilterChain}
63-
* @throws ServletException {@link ServletException}
64-
*/
65-
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
66-
throws IOException, ServletException {
67-
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
68-
String privacy = filterConfig.getInitParameter("privacy");
69-
String expirationTime = filterConfig.getInitParameter("expirationTime");
70-
71-
if (httpServletResponse != null && privacy != null && !"".equals(privacy) && expirationTime != null
72-
&& !"".equals(expirationTime)) {
73-
long seconds = Long.valueOf(expirationTime);
74-
75-
// set the provided HTTP response parameters
76-
httpServletResponse.setHeader("Cache-Control", privacy + ", max-age=" + seconds + ", must-revalidate");
77-
httpServletResponse.setDateHeader("Expires", System.currentTimeMillis() + seconds * 1000L);
78-
}
79-
80-
// pass the request/response on
81-
filterChain.doFilter(servletRequest, servletResponse);
82-
}
83-
}
1+
/*
2+
* $Id$
3+
*
4+
* Copyright 2008 samaxes.com
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.samaxes.filter;
19+
20+
import java.io.IOException;
21+
22+
import javax.servlet.Filter;
23+
import javax.servlet.FilterChain;
24+
import javax.servlet.FilterConfig;
25+
import javax.servlet.ServletException;
26+
import javax.servlet.ServletRequest;
27+
import javax.servlet.ServletResponse;
28+
import javax.servlet.http.HttpServletResponse;
29+
30+
/**
31+
* Filter responsible for browser caching.
32+
*
33+
* @author : Samuel Santos
34+
* @version : $Revision: 25 $
35+
*/
36+
public class CacheFilter implements Filter {
37+
38+
private FilterConfig filterConfig;
39+
40+
/**
41+
* Place this filter into service.
42+
*
43+
* @param filterConfig {@link FilterConfig}
44+
*/
45+
public void init(FilterConfig filterConfig) throws ServletException {
46+
this.filterConfig = filterConfig;
47+
}
48+
49+
/**
50+
* Take this filter out of service.
51+
*/
52+
public void destroy() {
53+
this.filterConfig = null;
54+
}
55+
56+
/**
57+
* Sets cache headers directives.
58+
*
59+
* @param servletRequest {@link ServletRequest}
60+
* @param servletResponse {@link ServletResponse}
61+
* @param filterChain {@link FilterChain}
62+
* @throws IOException {@link FilterChain}
63+
* @throws ServletException {@link ServletException}
64+
*/
65+
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
66+
throws IOException, ServletException {
67+
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
68+
String privacy = filterConfig.getInitParameter("privacy");
69+
String expirationTime = filterConfig.getInitParameter("expirationTime");
70+
71+
if (httpServletResponse != null && privacy != null && !"".equals(privacy) && expirationTime != null
72+
&& !"".equals(expirationTime)) {
73+
long seconds = Long.valueOf(expirationTime);
74+
75+
// set the provided HTTP response parameters
76+
httpServletResponse.setHeader("Cache-Control", privacy + ", max-age=" + seconds + ", must-revalidate");
77+
httpServletResponse.setDateHeader("Expires", System.currentTimeMillis() + seconds * 1000L);
78+
}
79+
80+
// pass the request/response on
81+
filterChain.doFilter(servletRequest, servletResponse);
82+
}
83+
}

0 commit comments

Comments
 (0)