java.lang.Object
net.i2p.jetty.JettyStart
All Implemented Interfaces:
ClientApp

public class JettyStartextends Object implements ClientApp
Start Jetty where the args are one or more XML files. Save a reference to the Server so it can be cleanly stopped later. Caller must call startup() This is like XmlConfiguration.main(String[]), which is essentially what org.mortbay.start.Main does.
  • Field Details

    • _mgr

      private final ClientAppManager _mgr
      The manager that starts the apps.
    • _args

      private final String[] _args
      The command line arguments given.
    • _jettys

      private final List<LifeCycle> _jettys
      The Jetty servers that were started.
    • _context

      private final I2PAppContext _context
      The app context, null when run standalone from main.
    • _state

      private volatile ClientAppState _state
      Current state of the server.
    • _port

      private volatile int _port
      The HTTP port in use.
    • _sslPort

      private volatile int _sslPort
      The HTTPS port in use.
    • GZIP_DIR

      private static final String GZIP_DIR
      Config directory for Jetty 9.3 and newer.
      See Also:
    • GZIP_CONFIG

      private static final String GZIP_CONFIG
      Config file enabling the gzip handler.
      See Also:
    • MIN_GZIP_HANDLER_VER

      private static final String MIN_GZIP_HANDLER_VER
      Oldest Jetty version with the gzip handler.
      See Also:
    • REWRITE_DIR

      private static final String REWRITE_DIR
      Config directory for the rewrite handler.
      See Also:
    • REWRITE_CONFIG

      private static final String REWRITE_CONFIG
      Config file enabling the rewrite handler.
      See Also:
  • Constructor Details

    • JettyStart

      public JettyStart(I2PAppContext context, ClientAppManager mgr, String[] args) throws Exception
      All args must be XML file names. Does not support any of the other argument types from org.mortbay.start.Main.
      Parameters:
      context - may be null
      mgr - may be null e.g. for use in plugins
      args - the XML configuration file names to load, one per entry
      Throws:
      Exception - if an argument is not a readable Jetty XML configuration file
  • Method Details

    • parseArgs

      private void parseArgs(String[] args) throws Exception
      Modified from XmlConfiguration.main()
      Parameters:
      args - the command line arguments, Jetty XML config files and properties
      Throws:
      Exception - if a Jetty XML configuration file cannot be read or applied
    • startup

      public void startup()
      Description copied from interface: ClientApp
      Do not take a long time. Do not block. Start threads here if necessary. Client must call ClientAppManager.notify(ClientApp, ClientAppState, String, Exception) at least once within this method to change the state from INITIALIZED to something else. Will not be called multiple times on the same object.
      Specified by:
      startup in interface ClientApp
    • shutdown

      public void shutdown(String[] args)
      Description copied from interface: ClientApp
      Do not take a long time. Do not block. Use a thread if necessary. If previously running, client must call ClientAppManager.notify(ClientApp, ClientAppState, String, Exception) at least once within this method to change the state to STOPPING or STOPPED. May be called multiple times on the same object, in any state.
      Specified by:
      shutdown in interface ClientApp
      Parameters:
      args - generally null but could be stopArgs from clients.config
    • getState

      public ClientAppState getState()
      Description copied from interface: ClientApp
      The current state of the ClientApp.
      Specified by:
      getState in interface ClientApp
      Returns:
      non-null
    • getName

      public String getName()
      Description copied from interface: ClientApp
      The generic name of the ClientApp, used for registration, e.g. "console". Do not translate.
      Specified by:
      getName in interface ClientApp
      Returns:
      non-null
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ClientApp
      The display name of the ClientApp, used in user interfaces. The app must translate.
      Specified by:
      getDisplayName in interface ClientApp
      Returns:
      non-null
    • changeState

      private void changeState(ClientAppState state)
      Changes the app state and notifies listeners.
      Parameters:
      state - the new state
    • changeState

      private void changeState(ClientAppState state, Exception e)
      Changes the app state and notifies listeners.
      Parameters:
      state - the new state
      e - the exception, null if none
    • main

      public static void main(String[] args)
      For use in a plugin clients.config
      Parameters:
      args - passed to constructor