Class QApplicationJavalinServer

java.lang.Object
com.kingsrook.qqq.middleware.javalin.QApplicationJavalinServer

public class QApplicationJavalinServer extends Object
Second-generation qqq javalin server. An evolution over the original QJavalinImplementation, which both managed the javalin instance itself, but also provided all of the endpoint handlers... This class instead just configures invalid input: '&' starts the server. Makes several setters available, to let application-developer choose what standard qqq endpoints are served (e.g., frontend-material-dashboard, the legacy-unversioned middleware, newer versioned-middleware, and additional qqq modules or application-defined services (both provided as instances of QJavalinRouteProviderInterface). System property `qqq.javalin.hotSwapInstance` (defaults to false), causes the QInstance to be re-loaded every X millis, to avoid some server restarts while doing dev. Admin dashboard selection: when the qqq-frontend-next jar is on the classpath its dashboard is served at "/" by default; otherwise the Material Dashboard is. Choose explicitly with withServeFrontendNext / withServeFrontendMaterialDashboard, or, when neither is set in code, with system property `qqq.javalin.frontend` set to `next`, `material` or `none`.
  • Constructor Details

    • QApplicationJavalinServer

      public QApplicationJavalinServer(AbstractQQQApplication application)
      Constructor
  • Method Details

    • start

      public void start() throws QException
      Throws:
      QException
    • stop

      public void stop()
    • hotSwapQInstance

      public void hotSwapQInstance()
      If there's a qInstanceHotSwapSupplier, and its been a little while, replace the qInstance with a new one from the supplier. Meant to be used while doing development.
    • getQInstance

      public QInstance getQInstance()
      Getter for the QInstance this server built from its application in start (or the latest one, when hot-swapping) - null before start.
    • getBoundPort

      public Integer getBoundPort()
      The port the running service is bound to (differs from getPort when the server was configured with port 0); the configured port before start.
    • isStrictUiApiRoutes

      public boolean isStrictUiApiRoutes()
      Whether routes under a UI API version without an endpoint spec fail startup (true, the default since UI API 1.3.0 / QRun-IO/qqq#1159) or are only logged as warnings (false). When not set, the system property qqq.uiApi.strictRoutes or the environment variable QQQ_UI_API_STRICT_ROUTES decides: only "false" turns strict mode off.
    • withStrictUiApiRoutes

      public QApplicationJavalinServer withStrictUiApiRoutes(boolean strictUiApiRoutes)
      Fluent setter for strictUiApiRoutes
    • getPort

      public Integer getPort()
      Getter for port
    • setPort

      public void setPort(Integer port)
      Setter for port
    • withPort

      public QApplicationJavalinServer withPort(Integer port)
      Fluent setter for port
    • getServeFrontendMaterialDashboard

      public boolean getServeFrontendMaterialDashboard()
      Whether the Material Dashboard is served: the explicit setting, else the `qqq.javalin.frontend` system property, else only when the Next dashboard is not being served.
    • setServeFrontendMaterialDashboard

      public void setServeFrontendMaterialDashboard(boolean serveFrontendMaterialDashboard)
      Setter for serveFrontendMaterialDashboard
    • withServeFrontendMaterialDashboard

      public QApplicationJavalinServer withServeFrontendMaterialDashboard(boolean serveFrontendMaterialDashboard)
      Fluent setter for serveFrontendMaterialDashboard
    • getServeFrontendNext

      public boolean getServeFrontendNext()
      Whether the Next dashboard is served at "/": the explicit setting, else the `qqq.javalin.frontend` system property, else when its jar is on the classpath and the Material Dashboard was not explicitly requested.
    • setServeFrontendNext

      public void setServeFrontendNext(boolean serveFrontendNext)
      Setter for serveFrontendNext
    • withServeFrontendNext

      public QApplicationJavalinServer withServeFrontendNext(boolean serveFrontendNext)
      Fluent setter for serveFrontendNext
    • getNextDashboardSecurityHeadersCustomizer

      public Consumer<NextDashboardSecurityHeaders> getNextDashboardSecurityHeadersCustomizer()
      Getter for nextDashboardSecurityHeadersCustomizer
    • setNextDashboardSecurityHeadersCustomizer

      public void setNextDashboardSecurityHeadersCustomizer(Consumer<NextDashboardSecurityHeaders> nextDashboardSecurityHeadersCustomizer)
      Setter for nextDashboardSecurityHeadersCustomizer: adjusts the Content-Security-Policy and other security headers the Next dashboard is served with (see NextDashboardSecurityHeaders). Set before start().
    • withNextDashboardSecurityHeadersCustomizer

      public QApplicationJavalinServer withNextDashboardSecurityHeadersCustomizer(Consumer<NextDashboardSecurityHeaders> nextDashboardSecurityHeadersCustomizer)
      Fluent setter for nextDashboardSecurityHeadersCustomizer, for example withNextDashboardSecurityHeadersCustomizer(headers -> headers.withSources("img-src", "https://cdn.example.com")).
    • getSessionCookieHttpOnly

      public boolean getSessionCookieHttpOnly()
      Whether session cookies (sessionUUID, sessionId) are HttpOnly: the explicit setting, else the `qqq.javalin.sessionCookieHttpOnly` system property, else on unless the Material Dashboard is served, because it reads sessionUUID in the browser (QRun-IO/qqq#733). An application whose Material Dashboard is served elsewhere on the same host should turn it off.
    • setSessionCookieHttpOnly

      public void setSessionCookieHttpOnly(Boolean sessionCookieHttpOnly)
      Setter for sessionCookieHttpOnly (see getSessionCookieHttpOnly).
    • withSessionCookieHttpOnly

      public QApplicationJavalinServer withSessionCookieHttpOnly(Boolean sessionCookieHttpOnly)
      Fluent setter for sessionCookieHttpOnly (see getSessionCookieHttpOnly).
    • getFrontendMaterialDashboardHostedPath

      public String getFrontendMaterialDashboardHostedPath()
      Getter for frontendMaterialDashboardHostedPath
    • setFrontendMaterialDashboardHostedPath

      public void setFrontendMaterialDashboardHostedPath(String frontendMaterialDashboardHostedPath)
      Setter for frontendMaterialDashboardHostedPath
    • withFrontendMaterialDashboardHostedPath

      public QApplicationJavalinServer withFrontendMaterialDashboardHostedPath(String frontendMaterialDashboardHostedPath)
      Fluent setter for frontendMaterialDashboardHostedPath
    • getServeLegacyUnversionedMiddlewareAPI

      public boolean getServeLegacyUnversionedMiddlewareAPI()
      Getter for serveLegacyUnversionedMiddlewareAPI
    • setServeLegacyUnversionedMiddlewareAPI

      public void setServeLegacyUnversionedMiddlewareAPI(boolean serveLegacyUnversionedMiddlewareAPI)
      Setter for serveLegacyUnversionedMiddlewareAPI
    • withServeLegacyUnversionedMiddlewareAPI

      public QApplicationJavalinServer withServeLegacyUnversionedMiddlewareAPI(boolean serveLegacyUnversionedMiddlewareAPI)
      Fluent setter for serveLegacyUnversionedMiddlewareAPI
    • getMiddlewareVersionList

      public List<AbstractMiddlewareVersion> getMiddlewareVersionList()
      Getter for middlewareVersionList
    • setMiddlewareVersionList

      public void setMiddlewareVersionList(List<AbstractMiddlewareVersion> middlewareVersionList)
      Setter for middlewareVersionList
    • withMiddlewareVersionList

      public QApplicationJavalinServer withMiddlewareVersionList(List<AbstractMiddlewareVersion> middlewareVersionList)
      Fluent setter for middlewareVersionList
    • getAdditionalRouteProviders

      public List<QJavalinRouteProviderInterface> getAdditionalRouteProviders()
      Getter for additionalRouteProviders
    • setAdditionalRouteProviders

      public void setAdditionalRouteProviders(List<QJavalinRouteProviderInterface> additionalRouteProviders)
      Setter for additionalRouteProviders
    • withAdditionalRouteProviders

      public QApplicationJavalinServer withAdditionalRouteProviders(List<QJavalinRouteProviderInterface> additionalRouteProviders)
      Fluent setter for additionalRouteProviders
    • withIsolatedSpaRouteProvider

      public QApplicationJavalinServer withIsolatedSpaRouteProvider(String spaPath, String staticFilesPath)
      Fluent setter to add an IsolatedSpaRouteProvider. Creates a basic SPA route provider for serving a single-page application with deep linking support at the specified path.
      Parameters:
      spaPath - The path where the SPA will be hosted (e.g., "/admin", "/")
      staticFilesPath - The classpath location of static files (e.g., "admin-spa/dist/")
      Returns:
      this server instance for method chaining
    • withIsolatedSpaRouteProvider

      public QApplicationJavalinServer withIsolatedSpaRouteProvider(String spaPath, String staticFilesPath, String spaIndexFile)
      Fluent setter to add an IsolatedSpaRouteProvider with full configuration. Creates an SPA route provider with an explicit index file path for serving a single-page application with deep linking support.
      Parameters:
      spaPath - The path where the SPA will be hosted (e.g., "/admin", "/")
      staticFilesPath - The classpath location of static files (e.g., "admin-spa/dist/")
      spaIndexFile - The classpath location of the index.html file (e.g., "admin-spa/dist/index.html")
      Returns:
      this server instance for method chaining
    • getMillisBetweenHotSwaps

      public long getMillisBetweenHotSwaps()
      Getter for MILLIS_BETWEEN_HOT_SWAPS
    • setMillisBetweenHotSwaps

      public void setMillisBetweenHotSwaps(long millisBetweenHotSwaps)
    • withMillisBetweenHotSwaps

      public QApplicationJavalinServer withMillisBetweenHotSwaps(long millisBetweenHotSwaps)
      Fluent setter for MILLIS_BETWEEN_HOT_SWAPS
    • getHotSwapCustomizer

      public Consumer<QInstance> getHotSwapCustomizer()
      Getter for hotSwapCustomizer
    • setHotSwapCustomizer

      public void setHotSwapCustomizer(Consumer<QInstance> hotSwapCustomizer)
      Setter for hotSwapCustomizer
    • withHotSwapCustomizer

      public QApplicationJavalinServer withHotSwapCustomizer(Consumer<QInstance> hotSwapCustomizer)
      Fluent setter for hotSwapCustomizer
    • getJavalinConfigCustomizer

      public Consumer<io.javalin.config.JavalinConfig> getJavalinConfigCustomizer()
      Getter for the callback that configures routes and handlers before creation.
    • setJavalinConfigCustomizer

      public void setJavalinConfigCustomizer(Consumer<io.javalin.config.JavalinConfig> javalinConfigCustomizer)
      Setter for the callback that configures routes and handlers before creation.
    • withJavalinConfigCustomizer

      public QApplicationJavalinServer withJavalinConfigCustomizer(Consumer<io.javalin.config.JavalinConfig> javalinConfigCustomizer)
      Fluent setter for configuration-time routes and handlers.
    • getJavalinConfigurationCustomizer

      public Consumer<io.javalin.Javalin> getJavalinConfigurationCustomizer()
      Getter for the service observer, called after route configuration.
    • setJavalinConfigurationCustomizer

      public void setJavalinConfigurationCustomizer(Consumer<io.javalin.Javalin> javalinConfigurationCustomizer)
      Setter for the service observer, called after route configuration.
    • withJavalinConfigurationCustomizer

      public QApplicationJavalinServer withJavalinConfigurationCustomizer(Consumer<io.javalin.Javalin> javalinConfigurationCustomizer)
      Fluent setter for the service observer; use javalinConfigCustomizer for routes.
    • getJavalinMetaData

      public QJavalinMetaData getJavalinMetaData()
      Getter for javalinMetaData
    • setJavalinMetaData

      public void setJavalinMetaData(QJavalinMetaData javalinMetaData)
      Setter for javalinMetaData
    • withJavalinMetaData

      public QApplicationJavalinServer withJavalinMetaData(QJavalinMetaData javalinMetaData)
      Fluent setter for javalinMetaData