1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.trinidad.webapp;
20
21 import java.io.IOException;
22
23 import javax.servlet.Filter;
24 import javax.servlet.FilterChain;
25 import javax.servlet.FilterConfig;
26 import javax.servlet.ServletException;
27 import javax.servlet.ServletRequest;
28 import javax.servlet.ServletResponse;
29
30 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
31
32
33
34
35
36
37
38
39 public class TrinidadFilter implements Filter
40 {
41 public void init(
42 FilterConfig filterConfig) throws ServletException
43 {
44 ClassLoader loader = Thread.currentThread().getContextClassLoader();
45 if (loader == null)
46 _LOG.severe("CANNOT_FIND_CONTEXT_CLASS_LOADER");
47 else
48 {
49 try
50 {
51 Class<?> proxiedClass = loader.loadClass(
52 "org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl");
53 _proxied = (Filter) proxiedClass.newInstance();
54 _proxied.init(filterConfig);
55 }
56 catch (ClassNotFoundException cnfe)
57 {
58 _LOG.severe(cnfe);
59 }
60 catch (IllegalAccessException iae)
61 {
62 _LOG.severe(iae);
63 }
64 catch (InstantiationException ie)
65 {
66 _LOG.severe(ie);
67 }
68 catch (RuntimeException e)
69 {
70
71 _LOG.severe(e);
72 throw e;
73 }
74 }
75
76
77 }
78
79 public void destroy()
80 {
81 if (_proxied != null)
82 _proxied.destroy();
83 _proxied = null;
84 }
85
86 public void doFilter(
87 ServletRequest request,
88 ServletResponse response,
89 FilterChain chain) throws IOException, ServletException
90 {
91 if (_proxied != null)
92 _proxied.doFilter(request, response, chain);
93 else
94 chain.doFilter(request, response);
95 }
96
97 private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(TrinidadFilter.class);
98
99 private Filter _proxied;
100 }