1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package nl.hippo.portal;
17
18 import javax.servlet.ServletContextEvent;
19 import javax.servlet.ServletContextListener;
20
21 import nl.hippo.portal.cms.CMSApplicationRegistry;
22 import nl.hippo.portal.registry.HippoPortalRegistry;
23
24 import org.springframework.web.context.WebApplicationContext;
25 import org.springframework.web.context.support.WebApplicationContextUtils;
26
27 /***
28 * @version $Id: PortalServletContentListener.java 6122 2007-04-18 14:34:48Z pduin $
29 *
30 */
31 public class PortalServletContentListener implements ServletContextListener
32 {
33
34
35
36 public void contextInitialized(ServletContextEvent event)
37 {
38 try
39 {
40 WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
41 CMSApplicationRegistry registry = (CMSApplicationRegistry)context.getBean(CMSApplicationRegistry.class.getName());
42 HippoPortalRegistry.getInstance().register(registry);
43 }
44 catch (Exception e)
45 {
46 if ( e instanceof RuntimeException )
47 {
48 throw (RuntimeException)e;
49 }
50 throw new RuntimeException(e);
51 }
52 }
53
54
55
56
57 public void contextDestroyed(ServletContextEvent event)
58 {
59 try
60 {
61 WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
62 CMSApplicationRegistry registry = (CMSApplicationRegistry)context.getBean(CMSApplicationRegistry.class.getName());
63 HippoPortalRegistry.getInstance().unregister(registry.getRegistryName());
64 }
65 catch (Exception e)
66 {
67 if ( e instanceof RuntimeException )
68 {
69 throw (RuntimeException)e;
70 }
71 throw new RuntimeException(e);
72 }
73 }
74 }