1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.orchestra.frameworkAdapter.springBasic;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.myfaces.orchestra.frameworkAdapter.basic.BasicFrameworkAdapter;
25 import org.apache.myfaces.orchestra.frameworkAdapter.basic.BasicFrameworkAdapterFilter;
26 import org.apache.myfaces.orchestra.lib._UrlMatcher;
27
28 import javax.servlet.Filter;
29 import javax.servlet.FilterChain;
30 import javax.servlet.FilterConfig;
31 import javax.servlet.ServletException;
32 import javax.servlet.ServletRequest;
33 import javax.servlet.ServletResponse;
34 import java.io.IOException;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public class SpringBasicFrameworkAdapterFilter implements Filter
53 {
54 private final static String INIT_CONVERSATION_MESSAGER = "conversationMessagerClass";
55
56 private final Log log = LogFactory.getLog(BasicFrameworkAdapterFilter.class);
57 private BasicFrameworkAdapter adapter;
58 private _UrlMatcher urlMatcher;
59
60 public void init(FilterConfig filterConfig) throws ServletException
61 {
62 String conversationMessager = filterConfig.getInitParameter(INIT_CONVERSATION_MESSAGER);
63
64 adapter = new SpringBasicFrameworkAdapter(filterConfig.getServletContext(), conversationMessager);
65 urlMatcher = new _UrlMatcher(filterConfig);
66 }
67
68 public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain filterChain)
69 throws IOException, ServletException
70 {
71 if (!urlMatcher.accept(req))
72 {
73 filterChain.doFilter(req, rsp);
74 return;
75 }
76
77 if (log.isDebugEnabled())
78 {
79 log.debug("doFilter");
80 }
81 try
82 {
83 adapter.beginRequest(req, rsp);
84 filterChain.doFilter(req, rsp);
85 }
86 finally
87 {
88 adapter.endRequest();
89 }
90 }
91
92 public void destroy()
93 {
94 }
95 }