隨筆-295  評論-26  文章-1  trackbacks-0

          public class PlatContextListener implements ServletContextListener{
          ??? private Timer timer = null;
          ??? /** 應(yīng)用程序的根目錄 */
          ??? private static String contextPath = null;
          ???
          ??? /** Creates a new instance of PlatContextListener */
          ??? public PlatContextListener() {
          ??? }

          ??? public void contextInitialized(ServletContextEvent sce) {
          ??????? ServletContext sc = sce.getServletContext();
          ??????? contextPath = sc.getRealPath("").replace("\\", "/");
          ???????
          ??????? int nInterval=24*60*60*1000;
          ???????
          ??????? timer = new Timer(true);
          ???????
          ??????? //每天零晨3點執(zhí)行清理工作
          ??????? Calendar calendar = Calendar.getInstance();
          ??????? calendar.set(Calendar.HOUR_OF_DAY,3);
          ??????? calendar.set(Calendar.MINUTE,0);
          ??????? calendar.set(Calendar.SECOND,0);
          ??????? Date time = calendar.getTime();
          ???
          ??????? timer.scheduleAtFixedRate(new PlatTimerClearTask(), time,nInterval);
          ???????

          ??? }

          ??? public void contextDestroyed(ServletContextEvent sce) {
          ??????? timer.cancel();
          ??? }
          ???
          ??? public static String getContextPath() {
          ??????? return contextPath;
          ??? }
          ???
          }



          大盤預(yù)測 國富論
          posted on 2007-10-11 14:50 華夢行 閱讀(165) 評論(0)  編輯  收藏 所屬分類: JDK
          主站蜘蛛池模板: 信宜市| 麦盖提县| 内乡县| 黄石市| 万盛区| 南充市| 凤山县| 特克斯县| 昭觉县| 那曲县| 吉林省| 龙江县| 商城县| 兴海县| 宁海县| 信宜市| 当雄县| 榆林市| 元江| 澎湖县| 拜泉县| 临海市| 甘孜| 新疆| 石台县| 海城市| 乌什县| 托克逊县| 珠海市| 长葛市| 顺平县| 大邑县| 肇庆市| 千阳县| 黄浦区| 盈江县| 根河市| 睢宁县| 习水县| 江川县| 亳州市|