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

          public class PlatContextListener implements ServletContextListener{
          ??? private Timer timer = null;
          ??? /** 應用程序的根目錄 */
          ??? 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點執行清理工作
          ??????? 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;
          ??? }
          ???
          }



          大盤預測 國富論
          posted on 2007-10-11 14:50 華夢行 閱讀(170) 評論(0)  編輯  收藏 所屬分類: JDK
          主站蜘蛛池模板: 新源县| 伊金霍洛旗| 六枝特区| 宝应县| 瑞丽市| 玛沁县| 甘南县| 靖宇县| 台山市| 盐城市| 寿宁县| 铁岭县| 呼和浩特市| 普洱| 武鸣县| 大理市| 清苑县| 湘潭市| 巴青县| 华阴市| 渭南市| 蒙山县| 岐山县| 五莲县| 仙居县| 乌鲁木齐县| 郎溪县| 柳河县| 玉林市| 海淀区| 西林县| 湟源县| 平原县| 延安市| 武强县| 集安市| 建德市| 贵阳市| 浪卡子县| 玛多县| 彰化县|