1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.webapp;
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24 import org.apache.myfaces.tobago.config.TobagoConfig;
25
26 import javax.faces.FactoryFinder;
27 import javax.faces.lifecycle.LifecycleFactory;
28 import javax.servlet.ServletContextEvent;
29 import javax.servlet.ServletContextListener;
30 import javax.servlet.ServletException;
31 import javax.servlet.http.HttpServlet;
32
33
34
35
36
37
38
39
40
41 public class WeblogicWorkaroundServlet extends HttpServlet {
42
43 private static final long serialVersionUID = -8636608446986072719L;
44
45 private static final Logger LOG = LoggerFactory.getLogger(WeblogicWorkaroundServlet.class);
46
47 public void init() throws ServletException {
48 if (LOG.isDebugEnabled()) {
49 LOG.debug("1st");
50 }
51 LifecycleFactory factory = (LifecycleFactory)
52 FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
53
54 if (factory == null) {
55 final String className = "com.sun.faces.config.ConfigureListener";
56 if (LOG.isDebugEnabled()) {
57 LOG.debug("Init of " + className + " by servlet!");
58 }
59 callInit(className);
60 }
61
62 if (LOG.isDebugEnabled()) {
63 LOG.debug("2nd");
64 }
65 TobagoConfig tobagoConfig = (TobagoConfig)
66 getServletContext().getAttribute(TobagoConfig.TOBAGO_CONFIG);
67
68 if (tobagoConfig == null) {
69 final String className = TobagoServletContextListener.class.getName();
70 if (LOG.isDebugEnabled()) {
71 LOG.debug("Init of " + className + " by servlet!");
72 }
73 callInit(className);
74 }
75
76 if (LOG.isDebugEnabled()) {
77 LOG.debug("3rd");
78 }
79 }
80
81 private void callInit(String className) {
82 try {
83 Class aClass = Class.forName(className);
84 ServletContextListener listener = (ServletContextListener) aClass.newInstance();
85 listener.contextInitialized(new ServletContextEvent(getServletContext()));
86 } catch (ClassNotFoundException e) {
87 LOG.error("", e);
88 } catch (IllegalAccessException e) {
89 LOG.error("", e);
90 } catch (InstantiationException e) {
91 LOG.error("", e);
92 }
93 }
94 }
95