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.jsf;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24
25 import javax.servlet.Filter;
26 import javax.servlet.FilterChain;
27 import javax.servlet.FilterConfig;
28 import javax.servlet.ServletException;
29 import javax.servlet.ServletRequest;
30 import javax.servlet.ServletResponse;
31 import java.io.IOException;
32
33 /***
34 * Configures the JsfFrameworkAdapter.
35 * <p>
36 * Orchestra accesses information about the request, response, session, etc via a
37 * FrameworkAdapter so that it can be used with multiple web tier frameworks. This
38 * class selects and configures the JSF version of this adapter.
39 * <p>
40 * Note that the conversation.jsf.OrchestraServletFilter class executes this class
41 * as a "subfilter", so defining this filter is not required if that filter is
42 * already defined.
43 * <p>
44 * If filter config parameter "conversationMessagerClass" is set, then this is
45 * passed to the BasicFrameworkAdapter, meaning that this can be either a
46 * beanname defined in the dependency-injection framework, or an absolute
47 * classname of a type implementing ConversationMessager.
48 */
49 public class JsfFrameworkAdapterFilter implements Filter
50 {
51 private final static String INIT_CONVERSATION_MESSAGER = "conversationMessagerClass";
52
53 private final Log log = LogFactory.getLog(JsfFrameworkAdapterFilter.class);
54 private JsfFrameworkAdapter adapter;
55
56 public void init(FilterConfig filterConfig) throws ServletException
57 {
58 String conversationMessager = filterConfig.getInitParameter(INIT_CONVERSATION_MESSAGER);
59
60 adapter = new JsfFrameworkAdapter(conversationMessager);
61 }
62
63 public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain filterChain) throws IOException, ServletException
64 {
65 log.debug("doFilter");
66 try
67 {
68 adapter.beginRequest(req, rsp);
69 filterChain.doFilter(req, rsp);
70 }
71 finally
72 {
73 adapter.endRequest();
74 }
75 }
76
77 public void destroy()
78 {
79 }
80 }