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 =
39 "org.apache.myfaces.orchestra.CONVERSATION_MESSAGER";
40
41 private final Log log = LogFactory.getLog(FrameworkAdapterRequestHandler.class);
42
43 private JsfFrameworkAdapter adapter;
44
45 public void init(FacesContext facesContext) throws FacesException
46 {
47 log.debug("init");
48
49 if (FrameworkAdapter.getCurrentInstance() == null)
50 {
51 log.debug("creating jsfFrameworkAdapter");
52
53 String conversationMessagerClass = getConversationMessagerClass(facesContext);
54 adapter = new JsfFrameworkAdapter(conversationMessagerClass);
55 adapter.beginRequest();
56 }
57 }
58
59 public void deinit() throws FacesException
60 {
61 if (adapter != null)
62 {
63 adapter.endRequest();
64 }
65 }
66
67 private static String getConversationMessagerClass(FacesContext facesContext)
68 {
69 ExternalContext ec = facesContext.getExternalContext();
70
71 String cn = ec.getInitParameter(CONVERSATION_MESSAGER_CLASS);
72 if (cn != null)
73 {
74 return cn;
75 }
76
77 cn = ec.getInitParameter(CoreConfig.CONVERSATION_MESSAGER);
78 return cn;
79 }
80 }