1 2 24 25 package com.lutris.appserver.server.sessionEnhydra; 26 27 import com.lutris.appserver.server.Application; 28 import com.lutris.appserver.server.Enhydra; 29 import com.lutris.logging.LogChannel; 30 import com.lutris.logging.Logger; 31 32 42 public class StandardSessionIdleTimer extends Thread { 43 44 private StandardSessionIdleHandler idleHandler; 45 private long scanInterval; private Application app; 48 59 public StandardSessionIdleTimer(StandardSessionIdleHandler manager, 60 Application app, 61 long scanIntervalSec) { 62 idleHandler = manager; 63 this.app = app; 64 scanInterval = scanIntervalSec * 1000; 66 setPriority(MIN_PRIORITY); setDaemon(true); } 69 70 75 public void run() { 76 if (app != null) { 77 Enhydra.register(app); 78 } 79 while (true) { 80 try { 81 sleep(scanInterval); 82 } catch (InterruptedException e) { 83 } 85 try { 86 idleHandler.cleanUpIdleSessions(); 87 } catch (Exception e) { 88 LogChannel log = Enhydra.getLogChannel(); 89 log.write(Logger.ALERT, "Failed to clean up idle sessions: " + e); 90 e.printStackTrace(); 92 } 93 } 94 } 96 97 100 public void shutdown() { 101 stop(); 102 } 103 } 104 105 | Popular Tags |