Class RunConfigurationWebServer

  • All Implemented Interfaces:
    IWebServerCompression

    public class RunConfigurationWebServer
    extends java.lang.Object
    implements IWebServerCompression
    Web server that is used when Run Configuration is used, an optimized Jetty Server for "raw Jetty" web socket communication that is used to run one iizi Module Project (that may refer to others, including Java projects).
    Author:
    Christopher Mindus
    • Constructor Detail

      • RunConfigurationWebServer

        public RunConfigurationWebServer​(java.lang.String root,
                                         IWSFileProviderServer fileProvider,
                                         IWSUploaderService uploaderService)
        Constructor.
        Parameters:
        root - The web server root.
        fileProvider - The external file provider, null for none.
    • Method Detail

      • getWebServerMapping

        public java.io.File getWebServerMapping​(java.lang.String mappedFile)
        Gets the map of web server mappings for files.
        Parameters:
        mappedFile - The file to map.
        Returns:
        The mapping from String (such as "dojo.root" or "iiziRunDevel.root") to File Returns null if not found.
      • startWebServer

        public void startWebServer​(IExternalBrowserPages extPages,
                                   WebSocketAcceptor acceptor,
                                   IServerSettings settings,
                                   PortConfig[] rcHttpConfig,
                                   PortConfig[] rcHttpsConfig,
                                   java.util.concurrent.Callable<java.lang.Void> redirCallback,
                                   ICommonServletInterface... servlets)
                            throws java.io.IOException
        Starts the web server.
        Parameters:
        extPages - External pages implementor, null for none.
        acceptor - The acceptor for engine requests.
        settings - The settings.
        rcHttpConfig - The first configuration set for HTTP, return value in index 0, null for none.
        rcHttpsConfig - The first configuration set for HTTPS, return value in index 0, null for none.
        redirCallback - Callback when redirections are ready.
        servlets - Servlets interface(s).
        Throws:
        java.io.IOException - For errors.
      • 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​(java.lang.String name,
                                       java.io.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​(java.io.File originalFile,
                                       java.io.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.
      • getStatistics

        public KString getStatistics()
        Gets the web server statistics as a HTML string.
        Returns:
        The web server statistics formatted as "[h1]Statistics:[/h1]...[h2]...[/h2]...", i.e. no body, no div's. If web server is not started, "[h1]Web server is not started[/h1]" is returned, and if the web server is stopped but has previously been running, "[h1]Web server is stopped[/h1]" is appended to the previous statistics.
      • getPushCache

        public java.util.Map<java.lang.String,​java.lang.String> getPushCache()
        Gets the push cache contents in an unsorted map with the 'Referer' as the key, and the value is a formatted string as size=number, [resource1, ..., resourceN].

        The push cache is based on the HTTP 'Referer' header.

        Returns:
        The push cache map. It is empty if the server is not running.
      • renewPushCache

        public void renewPushCache()
        Renews the push cache contents now.
      • clearPushCache

        public void clearPushCache()
        Clears the push cache contents now.