forked from I2P_Developers/i2p.i2p
Console: Remove static Server ref, hang off RCR
This commit is contained in:
@ -440,7 +440,7 @@ public class PluginStarter implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start console webapps in console/webapps
|
// start console webapps in console/webapps
|
||||||
ContextHandlerCollection server = WebAppStarter.getConsoleServer();
|
ContextHandlerCollection server = WebAppStarter.getConsoleServer(ctx);
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
File consoleDir = new File(pluginDir, "console");
|
File consoleDir = new File(pluginDir, "console");
|
||||||
Properties wprops = RouterConsoleRunner.webAppProperties(consoleDir.getAbsolutePath());
|
Properties wprops = RouterConsoleRunner.webAppProperties(consoleDir.getAbsolutePath());
|
||||||
@ -951,7 +951,7 @@ public class PluginStarter implements Runnable {
|
|||||||
Iterator <String> it = pluginWars.get(pluginName).iterator();
|
Iterator <String> it = pluginWars.get(pluginName).iterator();
|
||||||
while(it.hasNext() && !isWarRunning) {
|
while(it.hasNext() && !isWarRunning) {
|
||||||
String warName = it.next();
|
String warName = it.next();
|
||||||
if(WebAppStarter.isWebAppRunning(warName)) {
|
if(WebAppStarter.isWebAppRunning(ctx, warName)) {
|
||||||
isWarRunning = true;
|
isWarRunning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import java.util.StringTokenizer;
|
|||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
|
import net.i2p.app.ClientApp;
|
||||||
import net.i2p.app.ClientAppManager;
|
import net.i2p.app.ClientAppManager;
|
||||||
import net.i2p.app.ClientAppState;
|
import net.i2p.app.ClientAppState;
|
||||||
import static net.i2p.app.ClientAppState.*;
|
import static net.i2p.app.ClientAppState.*;
|
||||||
@ -100,7 +101,7 @@ public class RouterConsoleRunner implements RouterApp {
|
|||||||
private final RouterContext _context;
|
private final RouterContext _context;
|
||||||
private final ClientAppManager _mgr;
|
private final ClientAppManager _mgr;
|
||||||
private volatile ClientAppState _state = UNINITIALIZED;
|
private volatile ClientAppState _state = UNINITIALIZED;
|
||||||
private static Server _server;
|
private Server _server;
|
||||||
private static ScheduledExecutorScheduler _jettyTimer;
|
private static ScheduledExecutorScheduler _jettyTimer;
|
||||||
private String _listenPort;
|
private String _listenPort;
|
||||||
private String _listenHost;
|
private String _listenHost;
|
||||||
@ -116,6 +117,7 @@ public class RouterConsoleRunner implements RouterApp {
|
|||||||
// default changed from 0 (forever) in Jetty 6 to 60*1000 ms in Jetty 7
|
// default changed from 0 (forever) in Jetty 6 to 60*1000 ms in Jetty 7
|
||||||
authenticator.setMaxNonceAge(7*24*60*60*1000L);
|
authenticator.setMaxNonceAge(7*24*60*60*1000L);
|
||||||
}
|
}
|
||||||
|
private static final String NAME = "console";
|
||||||
public static final String JETTY_REALM = "i2prouter";
|
public static final String JETTY_REALM = "i2prouter";
|
||||||
private static final String JETTY_ROLE = "routerAdmin";
|
private static final String JETTY_ROLE = "routerAdmin";
|
||||||
public static final String PROP_CONSOLE_PW = "routerconsole.auth." + JETTY_REALM;
|
public static final String PROP_CONSOLE_PW = "routerconsole.auth." + JETTY_REALM;
|
||||||
@ -264,7 +266,7 @@ public class RouterConsoleRunner implements RouterApp {
|
|||||||
|
|
||||||
/** @since 0.9.4 */
|
/** @since 0.9.4 */
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "console";
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 0.9.4 */
|
/** @since 0.9.4 */
|
||||||
@ -281,14 +283,25 @@ public class RouterConsoleRunner implements RouterApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SInce _server is now static
|
* To get to Jetty
|
||||||
* @return may be null or stopped perhaps
|
* @return may be null or stopped perhaps
|
||||||
* @since Jetty 6 since it doesn't have Server.getServers()
|
* @since Jetty 6 since it doesn't have Server.getServers()
|
||||||
*/
|
*/
|
||||||
static Server getConsoleServer() {
|
synchronized Server getConsoleServer() {
|
||||||
return _server;
|
return _server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To get to Jetty
|
||||||
|
* @return may be null or stopped perhaps
|
||||||
|
* @since 0.9.38
|
||||||
|
*/
|
||||||
|
static Server getConsoleServer(I2PAppContext ctx) {
|
||||||
|
ClientApp app = ctx.clientAppManager().getRegisteredApp(NAME);
|
||||||
|
return (app != null) ? ((RouterConsoleRunner)app).getConsoleServer() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @since 0.8.13, moved from LogsHelper in 0.9.33 */
|
/** @since 0.8.13, moved from LogsHelper in 0.9.33 */
|
||||||
public static String jettyVersion() {
|
public static String jettyVersion() {
|
||||||
return Server.getVersion();
|
return Server.getVersion();
|
||||||
@ -1113,7 +1126,7 @@ public class RouterConsoleRunner implements RouterApp {
|
|||||||
String app = name.substring(PREFIX.length(), name.lastIndexOf(ENABLED));
|
String app = name.substring(PREFIX.length(), name.lastIndexOf(ENABLED));
|
||||||
if (ROUTERCONSOLE.equals(app))
|
if (ROUTERCONSOLE.equals(app))
|
||||||
continue;
|
continue;
|
||||||
if (WebAppStarter.isWebAppRunning(app)) {
|
if (WebAppStarter.isWebAppRunning(_context, app)) {
|
||||||
try {
|
try {
|
||||||
WebAppStarter.stopWebApp(_context, app);
|
WebAppStarter.stopWebApp(_context, app);
|
||||||
} catch (Throwable t) { t.printStackTrace(); }
|
} catch (Throwable t) { t.printStackTrace(); }
|
||||||
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
import net.i2p.util.FileUtil;
|
import net.i2p.util.FileUtil;
|
||||||
import net.i2p.util.PortMapper;
|
import net.i2p.util.PortMapper;
|
||||||
@ -150,7 +151,7 @@ public class WebAppStarter {
|
|||||||
* @since public since 0.9.33, was package private
|
* @since public since 0.9.33, was package private
|
||||||
*/
|
*/
|
||||||
public static void stopWebApp(RouterContext ctx, String appName) {
|
public static void stopWebApp(RouterContext ctx, String appName) {
|
||||||
ContextHandler wac = getWebApp(appName);
|
ContextHandler wac = getWebApp(ctx, appName);
|
||||||
if (wac == null)
|
if (wac == null)
|
||||||
return;
|
return;
|
||||||
ctx.portMapper().unregister(appName);
|
ctx.portMapper().unregister(appName);
|
||||||
@ -158,7 +159,7 @@ public class WebAppStarter {
|
|||||||
// not graceful is default in Jetty 6?
|
// not graceful is default in Jetty 6?
|
||||||
wac.stop();
|
wac.stop();
|
||||||
} catch (Exception ie) {}
|
} catch (Exception ie) {}
|
||||||
ContextHandlerCollection server = getConsoleServer();
|
ContextHandlerCollection server = getConsoleServer(ctx);
|
||||||
if (server == null)
|
if (server == null)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
@ -173,16 +174,16 @@ public class WebAppStarter {
|
|||||||
*
|
*
|
||||||
* @since public since 0.9.33; was package private
|
* @since public since 0.9.33; was package private
|
||||||
*/
|
*/
|
||||||
public static boolean isWebAppRunning(String appName) {
|
public static boolean isWebAppRunning(I2PAppContext ctx, String appName) {
|
||||||
ContextHandler wac = getWebApp(appName);
|
ContextHandler wac = getWebApp(ctx, appName);
|
||||||
if (wac == null)
|
if (wac == null)
|
||||||
return false;
|
return false;
|
||||||
return wac.isStarted();
|
return wac.isStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since Jetty 6 */
|
/** @since Jetty 6 */
|
||||||
static ContextHandler getWebApp(String appName) {
|
static ContextHandler getWebApp(I2PAppContext ctx, String appName) {
|
||||||
ContextHandlerCollection server = getConsoleServer();
|
ContextHandlerCollection server = getConsoleServer(ctx);
|
||||||
if (server == null)
|
if (server == null)
|
||||||
return null;
|
return null;
|
||||||
Handler handlers[] = server.getHandlers();
|
Handler handlers[] = server.getHandlers();
|
||||||
@ -203,8 +204,8 @@ public class WebAppStarter {
|
|||||||
* See comments in ConfigClientsHandler
|
* See comments in ConfigClientsHandler
|
||||||
* @since public since 0.9.33, was package private
|
* @since public since 0.9.33, was package private
|
||||||
*/
|
*/
|
||||||
public static ContextHandlerCollection getConsoleServer() {
|
public static ContextHandlerCollection getConsoleServer(I2PAppContext ctx) {
|
||||||
Server s = RouterConsoleRunner.getConsoleServer();
|
Server s = RouterConsoleRunner.getConsoleServer(ctx);
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return null;
|
return null;
|
||||||
Handler h = s.getChildHandlerByClass(ContextHandlerCollection.class);
|
Handler h = s.getChildHandlerByClass(ContextHandlerCollection.class);
|
||||||
|
@ -387,7 +387,7 @@ public class ConfigClientsHandler extends FormHandler {
|
|||||||
* requested and add the .war to that one
|
* requested and add the .war to that one
|
||||||
*/
|
*/
|
||||||
private void startWebApp(String app) {
|
private void startWebApp(String app) {
|
||||||
ContextHandlerCollection s = WebAppStarter.getConsoleServer();
|
ContextHandlerCollection s = WebAppStarter.getConsoleServer(_context);
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
try {
|
try {
|
||||||
File path = new File(_context.getBaseDir(), "webapps");
|
File path = new File(_context.getBaseDir(), "webapps");
|
||||||
|
@ -215,7 +215,7 @@ public class ConfigClientsHelper extends HelperBase {
|
|||||||
if (name.startsWith(RouterConsoleRunner.PREFIX) && name.endsWith(RouterConsoleRunner.ENABLED)) {
|
if (name.startsWith(RouterConsoleRunner.PREFIX) && name.endsWith(RouterConsoleRunner.ENABLED)) {
|
||||||
String app = name.substring(RouterConsoleRunner.PREFIX.length(), name.lastIndexOf(RouterConsoleRunner.ENABLED));
|
String app = name.substring(RouterConsoleRunner.PREFIX.length(), name.lastIndexOf(RouterConsoleRunner.ENABLED));
|
||||||
String val = props.getProperty(name);
|
String val = props.getProperty(name);
|
||||||
boolean isRunning = WebAppStarter.isWebAppRunning(app);
|
boolean isRunning = WebAppStarter.isWebAppRunning(_context, app);
|
||||||
String desc;
|
String desc;
|
||||||
// use descriptions already tagged elsewhere
|
// use descriptions already tagged elsewhere
|
||||||
if (app.equals("routerconsole"))
|
if (app.equals("routerconsole"))
|
||||||
|
Reference in New Issue
Block a user