net.i2p.router.web

## Class WebAppStarter

- java.lang.Object
- - net.i2p.router.web.WebAppStarter

-     public class WebAppStarter
      extends Object

  Add, start or stop a webapp. Add to the webapp classpath if specified in webapps.config. Sadly, setting Class-Path in MANIFEST.MF doesn't work for jetty wars. See WebAppConfiguration for more information. but let's just do it in webapps.config. No, wac.addClassPath() does not work. For more info see: http://servlets.com/archive/servlet/ReadMsg?msgId=511113&listName=jetty-support

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) static Map<String,String>` | `INIT_PARAMS`
    `(package private) static String` | `PARAM_PLUGIN_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebAppStarter()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) static WebAppContext` | `addWebApp(RouterContext ctx, ContextHandlerCollection server, String appName, String warPath, File tmpdir)` add but don't start This is used only by RouterConsoleRunner, which adds all the webapps first and then starts all at once.
    `static ContextHandlerCollection` | `getConsoleServer(I2PAppContext ctx)` See comments in ConfigClientsHandler Warning, this will NOT work during shutdown, because the console is already unregistered.
    `(package private) static ContextHandler` | `getWebApp(I2PAppContext ctx, String appName)` Warning, this will NOT work during shutdown, because the console is already unregistered.
    `(package private) static ContextHandler` | `getWebApp(Server s, String appName)`
    `static boolean` | `isWebAppRunning(I2PAppContext ctx, String appName)` As of 0.9.34, the appName will be registered with the PortMapper, and PortMapper.isRegistered() will be more efficient than this.
    `(package private) static boolean` | `isWebAppRunning(Server s, String appName)`
    `(package private) static void` | `setWebAppConfiguration(WebAppContext wac, boolean scanAnnotations)`
    `static void` | `startWebApp(RouterContext ctx, ContextHandlerCollection server, String appName, String warPath)` Adds and starts.
    `static void` | `startWebApp(RouterContext ctx, ContextHandlerCollection server, String appName, String warPath, String pluginName)` Adds and starts.
    `(package private) static void` | `stopWebApp(RouterContext ctx, Server s, String appName)` Stop it and remove the context.
    `static void` | `stopWebApp(RouterContext ctx, String appName)` Stop it and remove the context.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### INIT_PARAMS

          static final Map<String,String> INIT_PARAMS

    - #### PARAM_PLUGIN_NAME

          static final String PARAM_PLUGIN_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### WebAppStarter

          public WebAppStarter()

  - ### Method Detail

    - #### addWebApp

          static WebAppContext addWebApp(RouterContext ctx,
                                         ContextHandlerCollection server,
                                         String appName,
                                         String warPath,
                                         File tmpdir)
                                  throws IOException

      add but don't start This is used only by RouterConsoleRunner, which adds all the webapps first and then starts all at once.
      Throws:
        `IOException`

    - #### getConsoleServer

          public static ContextHandlerCollection getConsoleServer(I2PAppContext ctx)

      See comments in ConfigClientsHandler Warning, this will NOT work during shutdown, because the console is already unregistered.

    - #### getWebApp

          static ContextHandler getWebApp(I2PAppContext ctx,
                                          String appName)

      Warning, this will NOT work during shutdown, because the console is already unregistered.

    - #### getWebApp

          static ContextHandler getWebApp(Server s,
                                          String appName)

    - #### isWebAppRunning

          public static boolean isWebAppRunning(I2PAppContext ctx,
                                                String appName)

      As of 0.9.34, the appName will be registered with the PortMapper, and PortMapper.isRegistered() will be more efficient than this. Warning, this will NOT work during shutdown, because the console is already unregistered.

    - #### isWebAppRunning

          static boolean isWebAppRunning(Server s,
                                         String appName)

    - #### setWebAppConfiguration

          static void setWebAppConfiguration(WebAppContext wac,
                                             boolean scanAnnotations)

      Parameters:
        `scanAnnotations` - Should we check for Servlet 3.0 annotations? The war MUST be set to extract (due to Jetty bug), and annotation classes MUST be available

    - #### startWebApp

          public static void startWebApp(RouterContext ctx,
                                         ContextHandlerCollection server,
                                         String appName,
                                         String warPath)
                                  throws Exception

      Adds and starts. Prior to 0.9.28, was not guaranteed to throw on failure. Not for routerconsole.war, it's started in RouterConsoleRunner. Not for plugins, use 5-arg method. As of 0.9.34, the appName will be registered with the PortMapper.
      Throws:
        `Exception` - just about anything, caller would be wise to catch Throwable

    - #### startWebApp

          public static void startWebApp(RouterContext ctx,
                                         ContextHandlerCollection server,
                                         String appName,
                                         String warPath,
                                         String pluginName)
                                  throws Exception

      Adds and starts. Not for routerconsole.war, it's started in RouterConsoleRunner. The appName will be registered with the PortMapper.
      Parameters:
        `pluginName` - may be null, will look for console/webapps.config in that plugin
      Throws:
        `Exception` - just about anything, caller would be wise to catch Throwable

    - #### stopWebApp

          static void stopWebApp(RouterContext ctx,
                                 Server s,
                                 String appName)

      Stop it and remove the context. Throws just about anything, caller would be wise to catch Throwable

    - #### stopWebApp

          public static void stopWebApp(RouterContext ctx,
                                        String appName)

      Stop it and remove the context. Throws just about anything, caller would be wise to catch Throwable Warning, this will NOT work during shutdown, because the console is already unregistered.