01: package com.opensymphony.webwork.config;
02:
03: import javax.servlet.ServletContext;
04:
05: /**
06: * This singleton holds an instance of the web servlet context.
07: * <p/>
08: * This is needed for running WebWork on Weblogic Server 6.1
09: * because there is no provision to retrieve the servlet context
10: * from the web session object.
11: * <p/>
12: * This class is created to bet that this singleton can be set by
13: * {@link com.opensymphony.webwork.dispatcher.FilterDispatcherCompatWeblogic61}
14: * before the servlet context is needed by
15: * {@link com.opensymphony.webwork.lifecycle.SessionLifecycleListener}
16: * which will use this object to get it.
17: *
18: * @author Scott N. Smith scottnelsonsmith@yahoo.com
19: * @version $Id: ServletContextSingleton.java 897 2005-06-25 16:15:18Z plightbo $
20: */
21: public class ServletContextSingleton {
22: /**
23: * The web servlet context. Holding this is the
24: * purpose of this singleton.
25: */
26: private ServletContext servletContext;
27:
28: /**
29: * The sole instance of this class.
30: */
31: private static ServletContextSingleton singleton;
32:
33: /**
34: * Constructor which cannot be called
35: * publicly.
36: */
37: private ServletContextSingleton() {
38: }
39:
40: /**
41: * answers the singleton.
42: * <p/>
43: * At some point, the caller must populate the web servlet
44: * context.
45: *
46: * @return answers the singleton instance of this class
47: */
48: public static ServletContextSingleton getInstance() {
49: if (singleton == null) {
50: singleton = new ServletContextSingleton();
51: }
52: return singleton;
53: }
54:
55: /**
56: * @return the web servlet context
57: */
58: public ServletContext getServletContext() {
59: return servletContext;
60: }
61:
62: /**
63: * @param context the web servlet context
64: */
65: public void setServletContext(ServletContext context) {
66: servletContext = context;
67: }
68:
69: }
|