move getConsoleServer() method

This commit is contained in:
zzz
2010-02-18 16:33:47 +00:00
parent 3d8365a473
commit 82444f9e7b
5 changed files with 35 additions and 22 deletions

View File

@@ -254,7 +254,7 @@ public class ConfigClientsHandler extends FormHandler {
* requested and add the .war to that one
*/
private void startWebApp(String app) {
Server s = PluginStarter.getConsoleServer();
Server s = WebAppStarter.getConsoleServer();
if (s != null) {
try {
File path = new File(_context.getBaseDir(), "webapps");

View File

@@ -6,7 +6,6 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -23,7 +22,6 @@ import net.i2p.util.FileUtil;
import net.i2p.util.Log;
import net.i2p.util.Translate;
import org.mortbay.http.HttpListener;
import org.mortbay.jetty.Server;
@@ -93,7 +91,7 @@ public class PluginStarter implements Runnable {
}
// start console webapps in console/webapps
Server server = getConsoleServer();
Server server = WebAppStarter.getConsoleServer();
if (server != null) {
File consoleDir = new File(pluginDir, "console");
Properties props = RouterConsoleRunner.webAppProperties(consoleDir.getAbsolutePath());
@@ -185,7 +183,7 @@ public class PluginStarter implements Runnable {
}
// stop console webapps in console/webapps
Server server = getConsoleServer();
Server server = WebAppStarter.getConsoleServer();
if (server != null) {
File consoleDir = new File(pluginDir, "console");
Properties props = RouterConsoleRunner.webAppProperties(consoleDir.getAbsolutePath());
@@ -318,20 +316,6 @@ public class PluginStarter implements Runnable {
} catch (IOException ioe) {}
}
/** see comments in ConfigClientsHandler */
static Server getConsoleServer() {
Collection c = Server.getHttpServers();
for (int i = 0; i < c.size(); i++) {
Server s = (Server) c.toArray()[i];
HttpListener[] hl = s.getListeners();
for (int j = 0; j < hl.length; j++) {
if (hl[j].getPort() == 7657)
return s;
}
}
return null;
}
/** @param action "start" or "stop" or "uninstall" */
private static void runClientApps(RouterContext ctx, File pluginDir, List<ClientAppConfig> apps, String action) {
Log log = ctx.logManager().getLog(PluginStarter.class);

View File

@@ -2,12 +2,14 @@ package net.i2p.router.web;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Properties;
import java.util.StringTokenizer;
import net.i2p.I2PAppContext;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpListener;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.WebApplicationContext;
@@ -73,4 +75,17 @@ public class WebAppStarter {
} catch (InterruptedException ie) {}
}
/** see comments in ConfigClientsHandler */
static Server getConsoleServer() {
Collection c = Server.getHttpServers();
for (int i = 0; i < c.size(); i++) {
Server s = (Server) c.toArray()[i];
HttpListener[] hl = s.getListeners();
for (int j = 0; j < hl.length; j++) {
if (hl[j].getPort() == 7657)
return s;
}
}
return null;
}
}