Class QApplicationJavalinServer
java.lang.Object
com.kingsrook.qqq.middleware.javalin.QApplicationJavalinServer
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGetter for additionalRouteProvidersThe port the running service is bound to (differs from getPort when the server was configured with port 0); the configured port before start.Getter for frontendMaterialDashboardHostedPathGetter for hotSwapCustomizerConsumer<io.javalin.config.JavalinConfig> Getter for the callback that configures routes and handlers before creation.Consumer<io.javalin.Javalin> Getter for the service observer, called after route configuration.Getter for javalinMetaDataGetter for middlewareVersionListlongGetter for MILLIS_BETWEEN_HOT_SWAPSGetter for nextDashboardSecurityHeadersCustomizergetPort()Getter for portGetter for the QInstance this server built from its application in start (or the latest one, when hot-swapping) - null before start.booleanWhether 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.booleanWhether 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.booleanGetter for serveLegacyUnversionedMiddlewareAPIbooleanWhether 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).voidIf there's a qInstanceHotSwapSupplier, and its been a little while, replace the qInstance with a new one from the supplier.booleanWhether 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).voidsetAdditionalRouteProviders(List<QJavalinRouteProviderInterface> additionalRouteProviders) Setter for additionalRouteProvidersvoidsetFrontendMaterialDashboardHostedPath(String frontendMaterialDashboardHostedPath) Setter for frontendMaterialDashboardHostedPathvoidsetHotSwapCustomizer(Consumer<QInstance> hotSwapCustomizer) Setter for hotSwapCustomizervoidsetJavalinConfigCustomizer(Consumer<io.javalin.config.JavalinConfig> javalinConfigCustomizer) Setter for the callback that configures routes and handlers before creation.voidsetJavalinConfigurationCustomizer(Consumer<io.javalin.Javalin> javalinConfigurationCustomizer) Setter for the service observer, called after route configuration.voidsetJavalinMetaData(QJavalinMetaData javalinMetaData) Setter for javalinMetaDatavoidsetMiddlewareVersionList(List<AbstractMiddlewareVersion> middlewareVersionList) Setter for middlewareVersionListvoidsetMillisBetweenHotSwaps(long millisBetweenHotSwaps) voidsetNextDashboardSecurityHeadersCustomizer(Consumer<NextDashboardSecurityHeaders> nextDashboardSecurityHeadersCustomizer) Setter for nextDashboardSecurityHeadersCustomizer: adjusts the Content-Security-Policy and other security headers the Next dashboard is served with (see NextDashboardSecurityHeaders).voidSetter for portvoidsetServeFrontendMaterialDashboard(boolean serveFrontendMaterialDashboard) Setter for serveFrontendMaterialDashboardvoidsetServeFrontendNext(boolean serveFrontendNext) Setter for serveFrontendNextvoidsetServeLegacyUnversionedMiddlewareAPI(boolean serveLegacyUnversionedMiddlewareAPI) Setter for serveLegacyUnversionedMiddlewareAPIvoidsetSessionCookieHttpOnly(Boolean sessionCookieHttpOnly) Setter for sessionCookieHttpOnly (see getSessionCookieHttpOnly).voidstart()voidstop()withAdditionalRouteProviders(List<QJavalinRouteProviderInterface> additionalRouteProviders) Fluent setter for additionalRouteProviderswithFrontendMaterialDashboardHostedPath(String frontendMaterialDashboardHostedPath) Fluent setter for frontendMaterialDashboardHostedPathwithHotSwapCustomizer(Consumer<QInstance> hotSwapCustomizer) Fluent setter for hotSwapCustomizerwithIsolatedSpaRouteProvider(String spaPath, String staticFilesPath) Fluent setter to add an IsolatedSpaRouteProvider.withIsolatedSpaRouteProvider(String spaPath, String staticFilesPath, String spaIndexFile) Fluent setter to add an IsolatedSpaRouteProvider with full configuration.withJavalinConfigCustomizer(Consumer<io.javalin.config.JavalinConfig> javalinConfigCustomizer) Fluent setter for configuration-time routes and handlers.withJavalinConfigurationCustomizer(Consumer<io.javalin.Javalin> javalinConfigurationCustomizer) Fluent setter for the service observer; use javalinConfigCustomizer for routes.withJavalinMetaData(QJavalinMetaData javalinMetaData) Fluent setter for javalinMetaDatawithMiddlewareVersionList(List<AbstractMiddlewareVersion> middlewareVersionList) Fluent setter for middlewareVersionListwithMillisBetweenHotSwaps(long millisBetweenHotSwaps) Fluent setter for MILLIS_BETWEEN_HOT_SWAPSwithNextDashboardSecurityHeadersCustomizer(Consumer<NextDashboardSecurityHeaders> nextDashboardSecurityHeadersCustomizer) Fluent setter for nextDashboardSecurityHeadersCustomizer, for examplewithNextDashboardSecurityHeadersCustomizer(headers -> headers.withSources("img-src", "https://cdn.example.com")).Fluent setter for portwithServeFrontendMaterialDashboard(boolean serveFrontendMaterialDashboard) Fluent setter for serveFrontendMaterialDashboardwithServeFrontendNext(boolean serveFrontendNext) Fluent setter for serveFrontendNextwithServeLegacyUnversionedMiddlewareAPI(boolean serveLegacyUnversionedMiddlewareAPI) Fluent setter for serveLegacyUnversionedMiddlewareAPIwithSessionCookieHttpOnly(Boolean sessionCookieHttpOnly) Fluent setter for sessionCookieHttpOnly (see getSessionCookieHttpOnly).withStrictUiApiRoutes(boolean strictUiApiRoutes) Fluent setter for strictUiApiRoutes
-
Constructor Details
-
QApplicationJavalinServer
Constructor
-
-
Method Details
-
start
- 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
Getter for the QInstance this server built from its application in start (or the latest one, when hot-swapping) - null before start. -
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
Fluent setter for strictUiApiRoutes -
getPort
Getter for port -
setPort
Setter for port -
withPort
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
Fluent setter for serveFrontendNext -
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 examplewithNextDashboardSecurityHeadersCustomizer(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
Setter for sessionCookieHttpOnly (see getSessionCookieHttpOnly). -
withSessionCookieHttpOnly
Fluent setter for sessionCookieHttpOnly (see getSessionCookieHttpOnly). -
getFrontendMaterialDashboardHostedPath
Getter for frontendMaterialDashboardHostedPath -
setFrontendMaterialDashboardHostedPath
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
Getter for middlewareVersionList -
setMiddlewareVersionList
Setter for middlewareVersionList -
withMiddlewareVersionList
public QApplicationJavalinServer withMiddlewareVersionList(List<AbstractMiddlewareVersion> middlewareVersionList) Fluent setter for middlewareVersionList -
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
Fluent setter for MILLIS_BETWEEN_HOT_SWAPS -
getHotSwapCustomizer
-
setHotSwapCustomizer
-
withHotSwapCustomizer
Fluent setter for hotSwapCustomizer -
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
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
Getter for javalinMetaData -
setJavalinMetaData
Setter for javalinMetaData -
withJavalinMetaData
Fluent setter for javalinMetaData
-