1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jumpmind.symmetric.web;
22
23 import javax.servlet.Filter;
24 import javax.servlet.FilterConfig;
25 import javax.servlet.ServletException;
26
27 import org.apache.commons.logging.Log;
28 import org.jumpmind.symmetric.ext.IExtensionPoint;
29 import org.jumpmind.symmetric.transport.ITransportResource;
30 import org.springframework.beans.BeanUtils;
31
32 /***
33 * All symmetric filters (other than {@link SymmetricFilter}) should extend
34 * this class. It is managed by Spring.
35 *
36 * @since 1.4.0
37 */
38 public abstract class AbstractFilter extends ServletResourceTemplate implements Filter, IExtensionPoint {
39
40 protected abstract Log getLogger();
41
42 public void init(FilterConfig filterConfig) throws ServletException {
43 init(filterConfig.getServletContext());
44 if (isContainerCompatible() && !this.isSpringManaged()) {
45 final IServletResource springBean = getSpringBean();
46 if (this != springBean) {
47 if (getLogger().isInfoEnabled()) {
48 getLogger().info(String.format("Initializing filter %s", springBean.getClass().getSimpleName()));
49 }
50 BeanUtils.copyProperties(springBean, this, IServletResource.class);
51 BeanUtils.copyProperties(springBean, this, ITransportResource.class);
52 BeanUtils.copyProperties(springBean, this, this.getClass());
53 this.refresh();
54 }
55 }
56 }
57
58 public boolean isAutoRegister() {
59 return true;
60 }
61 }