1 41 package com.mvnforum; 42 43 import java.sql.Timestamp ; 44 45 import javax.servlet.*; 46 47 import net.myvietnam.mvncore.util.DateUtil; 48 import net.myvietnam.mvncore.util.FileUtil; 49 import org.apache.commons.logging.Log; 50 import org.apache.commons.logging.LogFactory; 51 52 public class MVNForumContextListener implements ServletContextListener { 53 54 private static Log log = LogFactory.getLog(MVNForumContextListener.class); 55 56 private static MVNForumContextListener instance; 57 58 private Timestamp startTimestamp; 59 60 63 private ServletContext context = null; 64 65 public MVNForumContextListener() { 66 instance = this; 67 } 68 69 70 75 public void contextInitialized(ServletContextEvent event) { 76 log.debug("contextInitialized"); 77 78 this.context = event.getServletContext(); 79 80 String realPath = context.getRealPath("/WEB-INF/classes"); FileUtil.setServletClassesPath(realPath); 82 startTimestamp = DateUtil.getCurrentGMTTimestamp(); 83 } 84 85 86 91 public void contextDestroyed(ServletContextEvent event) { 92 log.debug("contextDestroyed"); 93 94 this.context = null; 95 instance = null; 96 } 97 98 100 public static MVNForumContextListener getInstance() { 101 return instance; 102 } 103 104 public Timestamp getStartTimestamp() { 105 return startTimestamp; 106 } 107 108 } 109 | Popular Tags |