Package com. cqa. cms. utils;
Import java. SQL. SQLException;
Import java. util. List;
Import java. util. Timer;
Import java. util. TimerTask;
Import javax. servlet. ServletContext;
Import javax. servlet. ServletContextEvent;
Import javax. servlet. ServletContextListener;
Import org. springframework. web. context. support. WebApplicationContextUtils;
Import com. cqa. cms. entity. CMSColumn;
Import com. cqa. cms. service. IColumnTreeService;
Import com. cqa. cms. service. IStatisticsColumnService;
Public class TimerListener implements ServletContextListener {
Private Timer timer = null;
Public void contextDestroyed (ServletContextEvent arg0 ){
Timer. cancel ();
}
Public void contextInitialized (ServletContextEvent arg0 ){
Timer = new Timer ();
Timer. schedule (new RemoveTopTopicsTask (arg0.getServletContext (), 10000,100 0*6*1 );
}
Class RemoveTopTopicsTask extends TimerTask {
Private ServletContext context;
Public RemoveTopTopicsTask (ServletContext context ){
This. context = context;
}
@ Override
Public void run (){
IColumnTreeService columnTreeService = WebApplicationContextUtils. getWebApplicationContext (context). getBean ("columnTreeService", IColumnTreeService. class );
IStatisticsColumnService statisticsColumnService = WebApplicationContextUtils. getWebApplicationContext (context). getBean ("statisticsColumnService", IStatisticsColumnService. class );
Try {
List <CMSColumn> list = columnTreeService. columnsTree ();
StatisticsColumnService. accountStatistics (list );
System. out. println (list );
} Catch (SQLException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
}
}
}
Author "a729812804"