* Console, TunnelControllerGroup: Don't register shutdown hook if ClientAppManager is present

* JettyStart: Fixes for use by plugins
 * RouterAppManager: Add shutdown hook
This commit is contained in:
zzz
2013-04-24 15:45:15 +00:00
parent 57fd46d3a1
commit 813a1981d9
6 changed files with 75 additions and 14 deletions

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 13;
public final static long BUILD = 14;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -5,8 +5,10 @@ import java.io.Writer;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import net.i2p.app.*;
@ -35,6 +37,7 @@ public class RouterAppManager implements ClientAppManager {
_log = ctx.logManager().getLog(RouterAppManager.class);
_clients = new ConcurrentHashMap(16);
_registered = new ConcurrentHashMap(8);
ctx.addShutdownTask(new Shutdown());
}
/**
@ -166,6 +169,32 @@ public class RouterAppManager implements ClientAppManager {
return _registered.get(name);
}
/// end ClientAppManager interface
/**
* @since 0.9.6
*/
public synchronized void shutdown() {
Set<ClientApp> apps = new HashSet(_clients.keySet());
for (ClientApp app : apps) {
ClientAppState state = app.getState();
if (state == RUNNING || state == STARTING) {
try {
app.shutdown(null);
} catch (Throwable t) {}
}
}
}
/**
* @since 0.9.6
*/
public class Shutdown implements Runnable {
public void run() {
shutdown();
}
}
/**
* debug
* @since 0.9.6