1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.teeda.core.webapp; |
17 | |
|
18 | |
import javax.faces.FactoryFinder; |
19 | |
import javax.servlet.ServletContext; |
20 | |
import javax.servlet.ServletContextEvent; |
21 | |
|
22 | |
import org.seasar.framework.container.servlet.PortletExtendedS2ContainerListener; |
23 | |
import org.seasar.framework.log.Logger; |
24 | |
import org.seasar.teeda.core.ProductInfo; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | 0 | public class TeedaPortletExtendedConfigureListener extends |
32 | |
PortletExtendedS2ContainerListener { |
33 | |
|
34 | 0 | private static final String FACES_INIT_DONE = TeedaPortletExtendedConfigureListener.class |
35 | |
.getName() |
36 | |
+ ".FACES_INIT_DONE"; |
37 | |
|
38 | 0 | private static Logger logger = Logger |
39 | |
.getLogger(TeedaPortletExtendedConfigureListener.class); |
40 | |
|
41 | |
public void contextInitialized(ServletContextEvent event) { |
42 | 0 | super.contextInitialized(event); |
43 | 0 | printVersion(); |
44 | 0 | logger.debug("JSF initialize start"); |
45 | |
try { |
46 | 0 | initializeFaces(event.getServletContext()); |
47 | 0 | } catch (RuntimeException e) { |
48 | 0 | logger.log(e); |
49 | 0 | throw e; |
50 | 0 | } |
51 | 0 | logger.debug("JSF initialize end"); |
52 | 0 | } |
53 | |
|
54 | |
public void contextDestroyed(ServletContextEvent event) { |
55 | 0 | super.contextDestroyed(event); |
56 | 0 | FactoryFinder.releaseFactories(); |
57 | 0 | } |
58 | |
|
59 | |
protected void initializeFaces(ServletContext servletContext) { |
60 | 0 | Boolean b = (Boolean) servletContext.getAttribute(FACES_INIT_DONE); |
61 | 0 | boolean isAlreadyInitialized = (b != null) ? b.booleanValue() : false; |
62 | 0 | if (!isAlreadyInitialized) { |
63 | 0 | TeedaInitializer initializer = new TeedaInitializer(); |
64 | 0 | initializer.setServletContext(servletContext); |
65 | 0 | initializer.initializeFaces(); |
66 | 0 | servletContext.setAttribute(FACES_INIT_DONE, Boolean.TRUE); |
67 | |
} |
68 | |
|
69 | 0 | } |
70 | |
|
71 | |
private void printVersion() { |
72 | 0 | logger.debug("Teeda version :" + ProductInfo.getVersion()); |
73 | 0 | } |
74 | |
} |