01: /**
02: * Copyright 2002 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and iPlanet
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */package com.sun.portal.app.calendarcommon.calendar;
13:
14: import com.sun.portal.log.common.PortalLogger;
15: import java.util.logging.Level;
16: import java.util.logging.Logger;
17: import javax.servlet.ServletContext;
18: import javax.servlet.ServletContextEvent;
19: import javax.servlet.ServletContextListener;
20:
21: /**
22: *
23: *
24: * @author Nigel Jacobs
25: * @created May 20, 2005
26: *
27: */
28: public class DummySharedCalendarContextListener implements
29: ServletContextListener {
30:
31: private static Logger logger = PortalLogger
32: .getLogger(SharedCalendarContextListener.class);
33:
34: /**
35: * Create and cache a DummySharedCalendarUtils singleton for use by shared cal services.
36: *
37: * @param servletContextEvent
38: */
39: public void contextInitialized(
40: ServletContextEvent servletContextEvent) {
41:
42: if (logger.isLoggable(Level.FINE))
43: logger.fine("DummySharedCalCtxtLstnr INIT");
44:
45: ServletContext context = servletContextEvent
46: .getServletContext();
47: SharedCalendarUtils utils = new DummySharedCalendarUtilsImpl(); // dummy utils
48: context.setAttribute(
49: SharedCalendarUtils.SHARED_CAL_UTILS_CONTEXT_ATTR,
50: utils);
51:
52: }
53:
54: /**
55: * Clean up SharedCalendarUtils singleton.
56: * @param servletContextEvent
57: */
58: public void contextDestroyed(ServletContextEvent servletContextEvent) {
59:
60: if (logger.isLoggable(Level.FINE))
61: logger.fine("DummySharedCalCtxtLstnr DESTROY");
62:
63: ServletContext context = servletContextEvent
64: .getServletContext();
65: Object utils = context
66: .getAttribute(SharedCalendarUtils.SHARED_CAL_UTILS_CONTEXT_ATTR);
67: if (utils != null) {
68: if (utils instanceof SharedCalendarUtils) {
69: ((SharedCalendarUtils) utils).destroy();
70: }
71: context
72: .removeAttribute(SharedCalendarUtils.SHARED_CAL_UTILS_CONTEXT_ATTR);
73: }
74:
75: }
76:
77: }
|