/
CompressionFilter.java
105 lines (91 loc) · 3.38 KB
/
CompressionFilter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* SymmetricDS is an open source database synchronization solution.
*
* Copyright (C) Chris Henson <chenson42@users.sourceforge.net>,
* Keith Naas <knaas@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*/
package org.jumpmind.symmetric.web;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jumpmind.symmetric.common.ParameterConstants;
/**
*
* Configured within symmetric-web.xml
*
* <pre>
* <bean id="compressionFilter"
* class="org.jumpmind.symmetric.web.CompressionFilter">
* <property name="regexPattern" value="string" />
* <property name="regexPatterns">
* <list>
* <value value="string"/>
* <list/>
* <property/>
* <property name="uriPattern" value="string" />
* <property name="uriPatterns">
* <list>
* <value value="string"/>
* <list/>
* <property/>
* <property name="disabled" value="boolean" />
* <property name="compressionThreshold" value="int" />
* </bean>
* </pre>
*/
public class CompressionFilter extends AbstractFilter {
private static final Log logger = LogFactory.getLog(CompressionFilter.class);
private org.jumpmind.symmetric.web.compression.CompressionFilter delegate;
@Override
public boolean isContainerCompatible()
{
return true;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
if (delegate != null) {
delegate.doFilter(request, response, chain);
}
}
@Override
public void destroy() {
super.destroy();
if (delegate != null) {
delegate.destroy();
}
}
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
super.init(filterConfig);
delegate = new org.jumpmind.symmetric.web.compression.CompressionFilter();
delegate.init(filterConfig);
}
@Override
public boolean isDisabled() {
return parameterService.is(ParameterConstants.TRANSPORT_HTTP_COMPRESSION_DISABLED_SERVLET);
}
@Override
protected Log getLogger()
{
return logger;
}
}