隨筆-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 華夢行 閱讀(165) 評論(0)  編輯  收藏 所屬分類: JDK
          主站蜘蛛池模板: 荃湾区| 鄂尔多斯市| 宁阳县| 鸡东县| 额尔古纳市| 福建省| 宁河县| 广水市| 文安县| 二连浩特市| 呼伦贝尔市| 莫力| 海口市| 高碑店市| 华宁县| 青龙| 神池县| 长丰县| 南华县| 留坝县| 武功县| 泾川县| 苗栗县| 静宁县| 新竹县| 宣威市| 洪湖市| 逊克县| 卢龙县| 巴青县| 惠水县| 烟台市| 伊通| 界首市| 台前县| 台东市| 亳州市| 通城县| 中西区| 青冈县| 桓台县|