Class RunConfigurationWebServer
java.lang.Object
com.iizix.jetty.RunConfigurationWebServer
- All Implemented Interfaces:
IWebServerCompression, IWebServerDirectoryMapper
public class RunConfigurationWebServer extends Object implements IWebServerCompression, IWebServerDirectoryMapper
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
Field Summary
FieldsFields inherited from interface IWebServerCompression
INDEX_HTMLConstructor Summary
ConstructorsConstructorDescriptionRunConfigurationWebServer(String root, IWSFileProviderServer fileProvider, IWSUploaderService uploaderService, Map<String, File> dirMap) Method Summary
Modifier and TypeMethodDescriptionaddDirectoryMapping(String mappedFile, File directory) Adds a directory mapping for the web server to a directory.voidaddFileRedirection(File originalFile, File compressedfile) Puts a compressed file name into the resource cache of the web server.voidaddFileRedirection(String name, File file) Puts a compressed file name into the resource cache of the web server.Returns all the port configurations used for each request.Gets the web server statistics as a plain HTML text string.getWebServerDirectoryAlias(String alias) Gets the alias directory file for the web server.getWebServerMapping(String mappedFile) Gets the map of web server mappings for files.booleanregisterServlet(String pathSpec, HttpServlet servlet) Registers a servlet at a path specification in the root context, e.g.startWebServer(IExternalBrowserPages extPages, WebSocketAcceptor acceptor, IServerSettings settings, Callable<Void> redirCallback) Starts the web server.booleanstopWebServer(long maxTime) Stops the web server.booleanunregisterServlet(String pathSpec, HttpServlet servlet) Unregisters a servlet previously registered withregisterServlet(String,HttpServlet).
Field Details
server
The Jetty Server instance.
Constructor Details
RunConfigurationWebServer
public RunConfigurationWebServer(String root, IWSFileProviderServer fileProvider, IWSUploaderService uploaderService, Map<String, File> dirMap)
Method Details
getPortConfigurations
Returns all the port configurations used for each request.Please note that this call will return
nullif the server never has been not started.- Returns:
- All the port configurations used by the server, or
nullif the server never has been started.
getWebServerMapping
getWebServerDirectoryAlias
startWebServer
public PortConfig[] startWebServer(IExternalBrowserPages extPages, WebSocketAcceptor acceptor, IServerSettings settings, Callable<Void> redirCallback) throws IOException Starts the web server.- Parameters:
extPages- External pages implementor, null for none.acceptor- The acceptor for engine requests.settings- The settings.redirCallback- Callback when redirections are ready.- Returns:
- The port configuration array.
- Throws:
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.
registerServlet
Registers a servlet at a path specification in the root context, e.g."/iizi-push/*". The servlet takes precedence over the default servlet for every request whose path matches and answers every HTTP method itself, which is how a server module contributes an HTTP endpoint that receives POST. The web server may already be started: Jetty initializes a servlet added to a started context and rebuilds the path mappings.- Parameters:
pathSpec- The servlet path specification, must start with "/".servlet- The servlet.- Returns:
- true if registered, false if the path specification is already registered or the web server has not been started.
- Throws:
NullPointerException- If the web server is started andpathSpecorservletisnull.IllegalArgumentException- If the web server is started andpathSpecdoesn't start with "/".
unregisterServlet
Unregisters a servlet previously registered withregisterServlet(String,HttpServlet). A request to the path falls back to the default servlet afterwards.- Parameters:
pathSpec- The servlet path specification.servlet- The servlet, must be the registered instance.- Returns:
- true if unregistered, false if the path specification is not registered, the servlet is not the registered one, or the web server has not been started.
addFileRedirection
Puts a compressed file name into the resource cache of the web server.- Specified by:
addFileRedirectionin interfaceIWebServerCompression- Parameters:
name- The file name, typically "iizi*-build.css" or "iizi*-build.js".file- The compressed CSS or JS file.
addFileRedirection
Puts a compressed file name into the resource cache of the web server.- Specified by:
addFileRedirectionin interfaceIWebServerCompression- Parameters:
originalFile- The original uncompressed file.compressedfile- The compressed CSS or JS file.
addDirectoryMapping
public File addDirectoryMapping(String mappedFile, File directory) throws FileNotFoundException, IOException Adds a directory mapping for the web server to a directory.- Specified by:
addDirectoryMappingin interfaceIWebServerDirectoryMapper- Parameters:
mappedFile- The leading path from the web root directory to the directory being remapped.directory- The directory to map.- Returns:
- A previous mapping, or
nullif none is found. - Throws:
FileNotFoundException- If the directory does not exist.IOException- If the directory cannot be resolved to a canonical file.
getStatistics
Gets the web server statistics as a plain HTML text string.- Returns:
- The web server statistics formatted as
Statistics:\n - item: _item1\n - item2: _item2..., i.e. no body, no div's. If web server is not started,\n\n*** Web server is not started ***is returned. A warning message may be displayed in the server log in case of statistics generation failures.