Changeset 2de36ee


Ignore:
Timestamp:
Oct 11, 2018 1:10:33 PM (20 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
77e539a
Parents:
e68182a
Message:

Console: Remove static Server ref, hang off RCR

Location:
apps/routerconsole/java/src/net/i2p/router/web
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java

    re68182a r2de36ee  
    441441
    442442        // start console webapps in console/webapps
    443         ContextHandlerCollection server = WebAppStarter.getConsoleServer();
     443        ContextHandlerCollection server = WebAppStarter.getConsoleServer(ctx);
    444444        if (server != null) {
    445445            File consoleDir = new File(pluginDir, "console");
     
    952952            while(it.hasNext() && !isWarRunning) {
    953953                String warName = it.next();
    954                 if(WebAppStarter.isWebAppRunning(warName)) {
     954                if(WebAppStarter.isWebAppRunning(ctx, warName)) {
    955955                    isWarRunning = true;
    956956                }
  • apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java

    re68182a r2de36ee  
    2525
    2626import net.i2p.I2PAppContext;
     27import net.i2p.app.ClientApp;
    2728import net.i2p.app.ClientAppManager;
    2829import net.i2p.app.ClientAppState;
     
    101102    private final ClientAppManager _mgr;
    102103    private volatile ClientAppState _state = UNINITIALIZED;
    103     private static Server _server;
     104    private Server _server;
    104105    private static ScheduledExecutorScheduler _jettyTimer;
    105106    private String _listenPort;
     
    117118        authenticator.setMaxNonceAge(7*24*60*60*1000L);
    118119    }
     120    private static final String NAME = "console";
    119121    public static final String JETTY_REALM = "i2prouter";
    120122    private static final String JETTY_ROLE = "routerAdmin";
     
    265267    /** @since 0.9.4 */
    266268    public String getName() {
    267         return "console";
     269        return NAME;
    268270    }
    269271
     
    282284
    283285    /**
    284      *  SInce _server is now static
     286     *  To get to Jetty
    285287     *  @return may be null or stopped perhaps
    286288     *  @since Jetty 6 since it doesn't have Server.getServers()
    287289     */
    288     static Server getConsoleServer() {
     290    synchronized Server getConsoleServer() {
    289291        return _server;
    290292    }
     293
     294    /**
     295     *  To get to Jetty
     296     *  @return may be null or stopped perhaps
     297     *  @since 0.9.38
     298     */
     299    static Server getConsoleServer(I2PAppContext ctx) {
     300        ClientApp app = ctx.clientAppManager().getRegisteredApp(NAME);
     301        return (app != null) ? ((RouterConsoleRunner)app).getConsoleServer() : null;
     302    }
     303
    291304
    292305    /** @since 0.8.13, moved from LogsHelper in 0.9.33 */
     
    11141127                if (ROUTERCONSOLE.equals(app))
    11151128                    continue;
    1116                 if (WebAppStarter.isWebAppRunning(app)) {
     1129                if (WebAppStarter.isWebAppRunning(_context, app)) {
    11171130                    try {
    11181131                        WebAppStarter.stopWebApp(_context, app);
  • apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java

    re68182a r2de36ee  
    77import java.util.concurrent.ConcurrentHashMap;
    88
     9import net.i2p.I2PAppContext;
    910import net.i2p.router.RouterContext;
    1011import net.i2p.util.FileUtil;
     
    151152     */
    152153    public static void stopWebApp(RouterContext ctx, String appName) {
    153         ContextHandler wac = getWebApp(appName);
     154        ContextHandler wac = getWebApp(ctx, appName);
    154155        if (wac == null)
    155156            return;
     
    159160            wac.stop();
    160161        } catch (Exception ie) {}
    161         ContextHandlerCollection server = getConsoleServer();
     162        ContextHandlerCollection server = getConsoleServer(ctx);
    162163        if (server == null)
    163164            return;
     
    174175     *  @since public since 0.9.33; was package private
    175176     */
    176     public static boolean isWebAppRunning(String appName) {
    177         ContextHandler wac = getWebApp(appName);
     177    public static boolean isWebAppRunning(I2PAppContext ctx, String appName) {
     178        ContextHandler wac = getWebApp(ctx, appName);
    178179        if (wac == null)
    179180            return false;
     
    182183   
    183184    /** @since Jetty 6 */
    184     static ContextHandler getWebApp(String appName) {
    185         ContextHandlerCollection server = getConsoleServer();
     185    static ContextHandler getWebApp(I2PAppContext ctx, String appName) {
     186        ContextHandlerCollection server = getConsoleServer(ctx);
    186187        if (server == null)
    187188            return null;
     
    204205     *  @since public since 0.9.33, was package private
    205206     */
    206     public static ContextHandlerCollection getConsoleServer() {
    207         Server s = RouterConsoleRunner.getConsoleServer();
     207    public static ContextHandlerCollection getConsoleServer(I2PAppContext ctx) {
     208        Server s = RouterConsoleRunner.getConsoleServer(ctx);
    208209        if (s == null)
    209210            return null;
  • apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHandler.java

    re68182a r2de36ee  
    388388     */
    389389    private void startWebApp(String app) {
    390         ContextHandlerCollection s = WebAppStarter.getConsoleServer();
     390        ContextHandlerCollection s = WebAppStarter.getConsoleServer(_context);
    391391        if (s != null) {
    392392                    try {
  • apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHelper.java

    re68182a r2de36ee  
    216216                String app = name.substring(RouterConsoleRunner.PREFIX.length(), name.lastIndexOf(RouterConsoleRunner.ENABLED));
    217217                String val = props.getProperty(name);
    218                 boolean isRunning = WebAppStarter.isWebAppRunning(app);
     218                boolean isRunning = WebAppStarter.isWebAppRunning(_context, app);
    219219                String desc;
    220220                // use descriptions already tagged elsewhere
Note: See TracChangeset for help on using the changeset viewer.