2010-03-29 21:20:48 +00:00
|
|
|
package net.i2p.router.web;
|
|
|
|
|
2012-03-19 12:37:39 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2010-03-29 21:20:48 +00:00
|
|
|
import net.i2p.router.RouterContext;
|
|
|
|
import net.i2p.util.Log;
|
|
|
|
|
|
|
|
/**
|
2012-01-15 21:30:15 +00:00
|
|
|
* Stop all plugins that are installed and running
|
2010-03-29 21:20:48 +00:00
|
|
|
*
|
|
|
|
* @since 0.7.13
|
|
|
|
* @author zzz
|
|
|
|
*/
|
|
|
|
public class PluginStopper extends PluginStarter {
|
|
|
|
|
|
|
|
public PluginStopper(RouterContext ctx) {
|
|
|
|
super(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
stopPlugins(_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-01-15 21:30:15 +00:00
|
|
|
* Stop all running plugins
|
2010-03-29 21:20:48 +00:00
|
|
|
*
|
|
|
|
* this shouldn't throw anything
|
|
|
|
*/
|
2012-01-15 21:30:15 +00:00
|
|
|
private static void stopPlugins(RouterContext ctx) {
|
2010-03-29 21:20:48 +00:00
|
|
|
Log log = ctx.logManager().getLog(PluginStopper.class);
|
2012-03-19 12:37:39 +00:00
|
|
|
List<String> pl = getPlugins();
|
|
|
|
Collections.reverse(pl); // reverse the order
|
|
|
|
for (String app : pl) {
|
2012-01-15 21:30:15 +00:00
|
|
|
if (isPluginRunning(app, ctx)) {
|
|
|
|
try {
|
|
|
|
stopPlugin(ctx, app);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
if (log.shouldLog(Log.WARN))
|
|
|
|
log.warn("Failed to stop plugin: " + app, e);
|
|
|
|
}
|
2010-03-29 21:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|