Class WebServer

java.lang.Object
net.simplace.sim.wrapper.web.WebServer

public final class WebServer extends Object
Web client of SIMPLACE: a server of its own (Javalin, own port) that offers a browser page to run a solution, optionally with a project, a project table or a sensitivity analysis, to follow progress and log, to look at the CSV outputs as diagrams and to download them (see WebInterface). Like every binding it uses only the public SimplaceWrapper API; it is independent of the REST wrapper (net.simplace.sim.wrapper.rest).

The directories are set once at start, from the environment (main) or by FWSimConsole (command "web"), because FWSimEngine keeps them process-wide.

Environment variables (main):
  SIMPLACE_WORK_DIR      (required)
  SIMPLACE_OUTPUT_DIR    (required)
  SIMPLACE_PROJECTS_DIR  (optional, default = WORK_DIR)
  SIMPLACE_DATA_DIR      (optional, default = WORK_DIR)
  SIMPLACE_CHECK_LEVEL   (optional, e.g. LAZY/INTENSE/OFF)
  WEB_PORT               (optional, default 7080)
  SIMPLACE_WEB_CONFIG    (optional, default web.properties in the working directory: login, see WebConfig)
Started directly (main) or from FWSimConsole via reflection (command "web", see startFromConsole(Integer, String)): simplace_core itself must not compile against Javalin/Jetty (lib/rest), so FWSimConsole does not import this class.
Author:
Andreas Enders, Claude (Anthropic), co-author
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Port if neither WEB_PORT nor a port option is given.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    Configures the engine from the environment variables and starts the server.
    static void
    startFromConsole(Integer aPort, String aConfigFile)
    Entry point for FWSimConsole (command "web"); the directories are already set by FWSimConsole.
    static io.javalin.Javalin
    startOnPort(int aPort, WebConfig aConfig)
    Starts the server on a port and returns it (for tests: stop it afterwards).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_PORT

      public static final int DEFAULT_PORT
      Port if neither WEB_PORT nor a port option is given.
      See Also:
  • Method Details

    • main

      public static void main(String[] args)
      Configures the engine from the environment variables and starts the server.
      Parameters:
      args - not used
    • startFromConsole

      public static void startFromConsole(Integer aPort, String aConfigFile)
      Entry point for FWSimConsole (command "web"); the directories are already set by FWSimConsole.
      Parameters:
      aPort - port, null for WEB_PORT or 7080
      aConfigFile - properties file with the login, null for web.properties in the working directory
    • startOnPort

      public static io.javalin.Javalin startOnPort(int aPort, WebConfig aConfig)
      Starts the server on a port and returns it (for tests: stop it afterwards). Expects the engine directories to be set already.
      Parameters:
      aPort - port to listen on
      aConfig - login
      Returns:
      the started Javalin instance