📄 cleanupclass.java
字号:
/**
* Copyright (C) 2003 Manfred Andres
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package freecs.core;
import java.util.Iterator;
import freecs.*;
public class CleanupClass extends Thread {
public CleanupClass () {
}
public void run () {
Server.log ("CleanupClass starting to clean up", Server.MSG_STATE, Server.LVL_MAJOR);
Server.srv.startShutdown ();
MessageParser mpr = new MessageParser ();
mpr.setMessageTemplate ("message.server.shutdown");
Server.log ("CleanupClass sending shutdownmessages...", Server.MSG_STATE, Server.LVL_MAJOR);
Server.log ("Logout users...", Server.MSG_STATE, Server.LVL_MAJOR);
for (Iterator i = UserManager.mgr.users (); i.hasNext (); ) try {
User u = (User) i.next ();
u.sendMessage (mpr);
} catch (Exception e) {
Server.debug ("CleanupClass caused Exception while removing user: ", e, Server.MSG_STATE, Server.LVL_MAJOR);
}
Server.log ("Users logged out.", Server.MSG_STATE, Server.LVL_MAJOR);
Server.log ("Closing all connections...", Server.MSG_STATE, Server.LVL_MAJOR);
// 30000 millis before the CentralSelector will be forced to stop
long killTime = System.currentTimeMillis() + 30000;
while (!CentralSelector.stopped) try {
if (killTime < System.currentTimeMillis()) {
Server.log ("CentralSelector didn't shutdown within 30000 millis", Server.MSG_STATE, Server.LVL_VERBOSE);
break;
}
System.out.print (".");
Thread.sleep (100);
} catch (InterruptedException ie) {}
for (Iterator i = UserManager.mgr.users (); i.hasNext (); ) try {
User u = (User) i.next ();
i.remove();
} catch (Exception e) {
Server.debug ("CleanupClass caused Exception while removing user: ", e, Server.MSG_STATE, Server.LVL_MAJOR);
}
Server.log ("Shutting down authentication", Server.MSG_STATE, Server.LVL_MAJOR);
try {
Server.srv.auth.shutdown ();
} catch (Exception e) {
Server.debug ("CleanupClass caused Exception while shutting down authentication: ", e, Server.MSG_STATE, Server.LVL_MAJOR);
}
Server.log ("Final cleanup done. Exiting JVM.", Server.MSG_STATE, Server.LVL_MAJOR);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -