随笔-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 华梦行 阅读(151) 评论(0)  编辑  收藏 所属分类: JDK

只有注册用户登录后才能发表评论。


网站导航: