Commit 21177c06 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Use task engine instead of custom timer.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6250 b35dd754-fafc-0310-a699-88a17e54d16e
parent e897368f
...@@ -14,6 +14,7 @@ package org.jivesoftware.wildfire.http; ...@@ -14,6 +14,7 @@ package org.jivesoftware.wildfire.http;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveConstants; import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.TaskEngine;
import org.jivesoftware.wildfire.SessionManager; import org.jivesoftware.wildfire.SessionManager;
import org.jivesoftware.wildfire.StreamID; import org.jivesoftware.wildfire.StreamID;
import org.jivesoftware.wildfire.SessionPacketRouter; import org.jivesoftware.wildfire.SessionPacketRouter;
...@@ -71,8 +72,7 @@ public class HttpSessionManager { ...@@ -71,8 +72,7 @@ public class HttpSessionManager {
private SessionManager sessionManager; private SessionManager sessionManager;
private Map<String, HttpSession> sessionMap = new ConcurrentHashMap<String, HttpSession>(); private Map<String, HttpSession> sessionMap = new ConcurrentHashMap<String, HttpSession>();
private Timer inactivityTimer; private TimerTask inactivityTask;
private TimerTask inactivityThread;
static { static {
// Set the default read idle timeout. If none was set then assume 30 minutes // Set the default read idle timeout. If none was set then assume 30 minutes
...@@ -88,16 +88,13 @@ public class HttpSessionManager { ...@@ -88,16 +88,13 @@ public class HttpSessionManager {
} }
public void start() { public void start() {
inactivityThread = new HttpSessionReaper(); inactivityTask = new HttpSessionReaper();
inactivityTimer = new Timer("HttpSession Inactivity Timer"); TaskEngine.getInstance().schedule(inactivityTask, 30 * JiveConstants.SECOND,
inactivityTimer.schedule(inactivityThread, 30 * JiveConstants.SECOND,
30 * JiveConstants.SECOND); 30 * JiveConstants.SECOND);
} }
public void stop() { public void stop() {
inactivityTimer.cancel(); inactivityTask.cancel();
inactivityTimer = null;
inactivityThread = null;
for(HttpSession session : sessionMap.values()) { for(HttpSession session : sessionMap.values()) {
session.close(); session.close();
} }
...@@ -265,7 +262,7 @@ public class HttpSessionManager { ...@@ -265,7 +262,7 @@ public class HttpSessionManager {
public void run() { public void run() {
for(HttpSession session : sessionMap.values()) { for(HttpSession session : sessionMap.values()) {
long lastActive = (System.currentTimeMillis() - session.getLastActivity()) / 1000; long lastActive = (System.currentTimeMillis() - session.getLastActivity()) / 1000;
if(lastActive > session.getInactivityTimeout()) { if (lastActive > session.getInactivityTimeout()) {
session.close(); session.close();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment