Class IntegratedWebServer

java.lang.Object
com.iizix.jetty.IntegratedWebServer
All Implemented Interfaces:
IWebServerCompression

public class IntegratedWebServer extends Object implements IWebServerCompression
The Jetty integrated web server class in iiziGo Designer.
Author:
Christopher Mindus
  • Constructor Details

    • IntegratedWebServer

      public IntegratedWebServer(File parentDir, Map<String,File> redirect, String root)
      The constructor
  • Method Details

    • startWebServer

      public int startWebServer(IExternalBrowserPages extPages, IWSFileProviderServer fileProvider, WebSocketAcceptor acceptor, String extServerURL, PortConfig[] portConfigs, KeyStore keyStore, String pw, boolean useGzip)
      Starts the web server.
      Parameters:
      extPages - External pages implementor, null for none.
      fileProvider - File provider interface.
      acceptor - The acceptor for engine requests.
      extServerURL - External server URL, null to use canonical URL from ports.
      portConfigs - The port configurations.
      keyStore - The KeyStore to use, null for self-signed.
      pw - The KeyStore password, null for self-signed.
      useGzip - Flag to use GZip or not.
      Returns:
      The port used, 0 for failure, the first HTTP port is used if found, 0 otherwise.
    • startWebServer

      public int startWebServer(IExternalBrowserPages extPages, IWSFileProviderServer fileProvider, WebSocketAcceptor acceptor, String extServerURL, int[] offsets, IntFunction<PortConfig[]> portConfigsAt, KeyStore keyStore, String pw, boolean useGzip)
      Starts the web server on the first offset of a port range whose ports can all be bound (CC-FIX-PORT-RANGE-A, R-D-1..R-D-3): for each offset in turn the connectors of its port configurations are created and opened - bound - before the server starts, and a port another process holds makes the next offset be tried, with no probe that could race. HTTP and HTTPS move together, since one offset gives the configurations of both. When only the HTTP/3 (UDP) connector failed at every offset, the first offset whose TCP ports bound is taken without HTTP/3, said in a WARNING. The ports bound are read back from the connectors, so that a configured port 0 reports the port the operating system picked.
      Parameters:
      extPages - External pages implementor, null for none.
      fileProvider - File provider interface.
      acceptor - The acceptor for engine requests.
      extServerURL - External server URL, null to use canonical URL from ports.
      offsets - The offsets to try, in order.
      portConfigsAt - The port configurations of an offset.
      keyStore - The KeyStore to use, null for self-signed.
      pw - The KeyStore password, null for self-signed.
      useGzip - Flag to use GZip or not.
      Returns:
      The HTTP port bound, 0 for failure: getStartFailure() then says what failed.
    • setRemoteDesignerAllowed

      public void setRemoteDesignerAllowed(BooleanSupplier allowRemote)
      Sets whether the Designer's editor endpoints - the external-browser Designer page, its WebSocket and the tooltip preview - answer a client on another computer (EB-3, CC-FIX-PORT-RANGE-A). Asked per request, so a change of the preference applies at once. Set before startWebServer; null (the default) installs no gate.
      Parameters:
      allowRemote - Answers true when other computers are allowed, null for no gate.
    • getStartFailure

      public String getStartFailure()
      Gets what made the last start fail.
      Returns:
      The failure, one entry per offset tried; null when the last start did not fail.
    • getBoundOffset

      public int getBoundOffset()
      Gets the offset of the port range the server bound.
      Returns:
      The offset, -1 when not started.
    • getHttp3Port

      public int getHttp3Port()
      Gets the UDP port of the HTTP/3 connector.
      Returns:
      The port, zero for none (HTTP/3 off, or no HTTPS).
    • getExternalServerURL

      public String getExternalServerURL()
      Returns the external server URL.
      Returns:
      The external web server base URL, or null for none.
    • getWebServerPort

      public int getWebServerPort()
      Gets the started web server port.
      Returns:
      The port number, zero for not started.
    • getSecureWebServerPort

      public int getSecureWebServerPort()
      Gets the started secure (HTTPS) web server port.
      Returns:
      The port number, zero for not started.
    • stopWebServer

      public boolean stopWebServer(long maxTime)
      Stops the web server.
      Parameters:
      maxTime - Max time to wait for server to stop, <=0 is forever.
      Returns:
      true for success, false for timeout.
    • addFileRedirection

      public void addFileRedirection(String name, File file)
      Puts a compressed file name into the resource cache of the web server.
      Specified by:
      addFileRedirection in interface IWebServerCompression
      Parameters:
      name - The file name, typically "iizi*-build.css" or "iizi*-build.js".
      file - The compressed CSS or JS file.
    • addFileRedirection

      public void addFileRedirection(File originalFile, File compressedfile)
      Puts a compressed file name into the resource cache of the web server.
      Specified by:
      addFileRedirection in interface IWebServerCompression
      Parameters:
      originalFile - The original uncompressed file.
      compressedfile - The compressed CSS or JS file.
    • startAgainWebServer

      public int startAgainWebServer(String extServerURL, PortConfig[] portConfigs, KeyStore keyStore, String pw, boolean useGzip)
      Restarts the web server once it is stopped.
      Parameters:
      extServerURL - External server URL, null to use canonical URL from ports.
      portConfigs - The port configurations.
      keyStore - The KeyStore to use, null for self-signed.
      pw - The KeyStore password, null for self-signed.
      useGzip - Flag to use GZip or not.
      Returns:
      The port used, 0 for failure, the first HTTP port is used if found, 0 otherwise.