java.lang.Object
net.i2p.jetty.JettyStart
- All Implemented Interfaces:
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.Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classThread starting the server.private classThread stopping the server.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String[]The command line arguments given.private final I2PAppContextThe app context, null when run standalone from main.The Jetty servers that were started.private final ClientAppManagerThe manager that starts the apps.private intThe HTTP port in use.private intThe HTTPS port in use.private ClientAppStateCurrent state of the server.private static final StringConfig file enabling the gzip handler.private static final StringConfig directory for Jetty 9.3 and newer.private static final StringOldest Jetty version with the gzip handler.private static final StringConfig file enabling the rewrite handler.private static final StringConfig directory for the rewrite handler.Constructor Summary
ConstructorsConstructorDescriptionJettyStart(I2PAppContext context, ClientAppManager mgr, String[] args) All args must be XML file names.Method Summary
Modifier and TypeMethodDescriptionprivate voidchangeState(ClientAppState state) Changes the app state and notifies listeners.private voidchangeState(ClientAppState state, Exception e) Changes the app state and notifies listeners.The display name of the ClientApp, used in user interfaces.getName()The generic name of the ClientApp, used for registration, e.g.getState()The current state of the ClientApp.static voidFor use in a plugin clients.configprivate voidModified from XmlConfiguration.main()voidDo not take a long time.voidstartup()Do not take a long time.
Field Details
_mgr
The manager that starts the apps._args
The command line arguments given._jettys
_context
The app context, null when run standalone from main._state
Current state of the server._port
private volatile int _portThe HTTP port in use._sslPort
private volatile int _sslPortThe HTTPS port in use.GZIP_DIR
Config directory for Jetty 9.3 and newer.- See Also:
GZIP_CONFIG
Config file enabling the gzip handler.- See Also:
MIN_GZIP_HANDLER_VER
Oldest Jetty version with the gzip handler.- See Also:
REWRITE_DIR
Config directory for the rewrite handler.- See Also:
REWRITE_CONFIG
Config file enabling the rewrite handler.- See Also:
Constructor Details
JettyStart
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 nullmgr- may be null e.g. for use in pluginsargs- 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
startup
public void startup()Description copied from interface:ClientAppDo not take a long time. Do not block. Start threads here if necessary. Client must callClientAppManager.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.shutdown
Description copied from interface:ClientAppDo not take a long time. Do not block. Use a thread if necessary. If previously running, client must callClientAppManager.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.getState
Description copied from interface:ClientAppThe current state of the ClientApp.getName
getDisplayName
Description copied from interface:ClientAppThe display name of the ClientApp, used in user interfaces. The app must translate.- Specified by:
getDisplayNamein interfaceClientApp- Returns:
- non-null
changeState
Changes the app state and notifies listeners.- Parameters:
state- the new state
changeState
Changes the app state and notifies listeners.- Parameters:
state- the new statee- the exception, null if none
main
For use in a plugin clients.config- Parameters:
args- passed to constructor