/**
 * 定时统计在线人数
 
*/

public class PreTestSelRunner {
    
    
    
private static PreTestSel preTestSel;

    
/**
     * 定时执行--静态方法(避免重复执行)

     * 
@param conn
     * 
@throws Exception
     
*/

    
public static void load() throws Exception {

        
//间隔时间设置,10分钟
        long period = 10*1000*60;
        
        PreTestSelRunner.preTestSel 
= new PreTestSel(period);
    }


    
/**
     * 定时调用主方法

     * 
     * PreTestSel.run()
     
*/

    
public static void run() {

        
try {
            
            TkGameBeanFactoryPlugin BeanPlugin 
= TkGameBeanFactoryPlugin.getIntance();
            RuntimeSettingsPlugInBL runtimeSettingsPlugInBL 
= (RuntimeSettingsPlugInBL) BeanPlugin.getBean("runtimeSettingsPlugInBL");

            
            
try {
                
                
//增加统计在线人数记录
                List list = runtimeSettingsPlugInBL.getBRSsoByServer();
                
                
for(int i=0;i<list.size();i++){
                    
                    
                    Game12OnlineLog obj 
= new Game12OnlineLog();
                    obj.setLogtime(
new Date());
                    obj.setServerno(list.get(i).toString());
                    obj.setValue(Integer.parseInt(list.get(i
+1).toString()));
                    
                    runtimeSettingsPlugIn2BL.saveOnlineLog(obj);

                    i
=i+1;
                }

                
            }
 catch (Exception e) {
                
                e.printStackTrace();
            }
 

                
        }
 catch (Exception ex) {
            System.out.println(
"run() error!!");
        }


    }


    

}
/**
 * 定时统计在线人数
 * 
 
*/

public class PreTestSel extends TimerTask {

    
private Timer timer;
    
    
/**
     * 
     * 
@param firstTime
     * 
@throws Exception
     
*/

    
public PreTestSel(long period) throws Exception {
        
        
this.timer = new Timer(true);
        
this.timer.schedule(this0, period);
    }

    
    
public void destroy() {
        
        
this.timer.cancel();
    }


    
public void run() {
        
        PreTestSelRunner.run();
    }

}