隨筆-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
          主站蜘蛛池模板: 璧山县| 靖边县| 金寨县| 安多县| 石景山区| 分宜县| 和平县| 麻江县| 大安市| 五台县| 望江县| 河北省| 上思县| 白山市| 彭泽县| 大厂| 正阳县| 申扎县| 会理县| 白沙| 南陵县| 进贤县| 渑池县| 江山市| 濮阳市| 丹阳市| 奉新县| 禹州市| 庐江县| 凉城县| 西乌珠穆沁旗| 威海市| 潍坊市| 旅游| 吴忠市| 樟树市| 阿克苏市| 衡阳县| 漳平市| 盐池县| 固阳县|