1
2
3
4
5 package org.directdemocracyportal.democracy.web;
6
7 import javax.servlet.ServletContextEvent;
8
9 import org.springframework.web.context.ContextLoaderListener;
10 import org.springframework.web.context.WebApplicationContext;
11 import org.springframework.web.context.support.WebApplicationContextUtils;
12
13 /***
14 * The listener interface for receiving staticContextLoader events.
15 * The class that is interested in processing a staticContextLoader
16 * event implements this interface, and the object created
17 * with that class is registered with a component using the
18 * component's <code>addStaticContextLoaderListener<code> method. When
19 * the staticContextLoader event occurs, that object's appropriate
20 * method is invoked.
21 *
22 * @see StaticContextLoaderEvent
23 */
24 public class StaticContextLoaderListener extends ContextLoaderListener
25 {
26
27 /*** The web app ctx. */
28 private static WebApplicationContext webAppCtx = null;
29
30
31
32
33
34
35 @Override
36 public void contextInitialized(ServletContextEvent event) {
37 super.contextInitialized(event);
38 webAppCtx = WebApplicationContextUtils
39 .getRequiredWebApplicationContext(event.getServletContext());
40 }
41
42
43
44
45
46
47 @Override
48 public void contextDestroyed(ServletContextEvent event) {
49 webAppCtx = null;
50 super.contextDestroyed(event);
51 }
52
53 /***
54 * Gets the web application context.
55 *
56 * @return the web application context
57 */
58 public static WebApplicationContext getWebApplicationContext() {
59 return webAppCtx;
60 }
61 }