1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.orchestra.lib.jsf;
20
21 import javax.faces.FacesException;
22 import javax.faces.context.ExternalContext;
23 import javax.faces.context.FacesContext;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.myfaces.orchestra.CoreConfig;
28 import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
29 import org.apache.myfaces.orchestra.frameworkAdapter.jsf.JsfFrameworkAdapter;
30
31
32
33
34
35
36 class FrameworkAdapterRequestHandler implements RequestHandler
37 {
38 private final static String CONVERSATION_MESSAGER_CLASS = "org.apache.myfaces.orchestra.CONVERSATION_MESSAGER";
39
40 private final Log log = LogFactory.getLog(FrameworkAdapterRequestHandler.class);
41
42 private JsfFrameworkAdapter adapter;
43
44 public void init(FacesContext facesContext) throws FacesException
45 {
46 log.debug("init");
47
48 if (FrameworkAdapter.getCurrentInstance() == null)
49 {
50 log.debug("creating jsfFrameworkAdapter");
51
52 String conversationMessagerClass = getConversationMessagerClass(facesContext);
53 adapter = new JsfFrameworkAdapter(conversationMessagerClass);
54 adapter.beginRequest();
55 }
56 }
57
58 public void deinit() throws FacesException
59 {
60 if (adapter != null)
61 {
62 adapter.endRequest();
63 }
64 }
65
66 private static String getConversationMessagerClass(FacesContext facesContext)
67 {
68 ExternalContext ec = facesContext.getExternalContext();
69
70 String cn = ec.getInitParameter(CONVERSATION_MESSAGER_CLASS);
71 if (cn != null)
72 {
73 return cn;
74 }
75
76 cn = ec.getInitParameter(CoreConfig.CONVERSATION_MESSAGER);
77 return cn;
78 }
79 }