mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
CE-1955 add checks for material-dashboard resources before trying to blindly serve them; add field for QJavalinMetaData;
This commit is contained in:
@ -33,6 +33,7 @@ import com.kingsrook.qqq.backend.core.utils.ClassPathUtils;
|
|||||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||||
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||||
import com.kingsrook.qqq.backend.javalin.QJavalinImplementation;
|
import com.kingsrook.qqq.backend.javalin.QJavalinImplementation;
|
||||||
|
import com.kingsrook.qqq.backend.javalin.QJavalinMetaData;
|
||||||
import com.kingsrook.qqq.middleware.javalin.specs.AbstractMiddlewareVersion;
|
import com.kingsrook.qqq.middleware.javalin.specs.AbstractMiddlewareVersion;
|
||||||
import com.kingsrook.qqq.middleware.javalin.specs.v1.MiddlewareVersionV1;
|
import com.kingsrook.qqq.middleware.javalin.specs.v1.MiddlewareVersionV1;
|
||||||
import io.javalin.Javalin;
|
import io.javalin.Javalin;
|
||||||
@ -69,6 +70,7 @@ public class QApplicationJavalinServer
|
|||||||
private List<AbstractMiddlewareVersion> middlewareVersionList = List.of(new MiddlewareVersionV1());
|
private List<AbstractMiddlewareVersion> middlewareVersionList = List.of(new MiddlewareVersionV1());
|
||||||
private List<QJavalinRouteProviderInterface> additionalRouteProviders = null;
|
private List<QJavalinRouteProviderInterface> additionalRouteProviders = null;
|
||||||
private Consumer<Javalin> javalinConfigurationCustomizer = null;
|
private Consumer<Javalin> javalinConfigurationCustomizer = null;
|
||||||
|
private QJavalinMetaData javalinMetaData = null;
|
||||||
|
|
||||||
private long lastQInstanceHotSwapMillis;
|
private long lastQInstanceHotSwapMillis;
|
||||||
private long millisBetweenHotSwaps = 2500;
|
private long millisBetweenHotSwaps = 2500;
|
||||||
@ -100,6 +102,11 @@ public class QApplicationJavalinServer
|
|||||||
{
|
{
|
||||||
if(serveFrontendMaterialDashboard)
|
if(serveFrontendMaterialDashboard)
|
||||||
{
|
{
|
||||||
|
if(getClass().getResource("/material-dashboard/index.html") == null)
|
||||||
|
{
|
||||||
|
LOG.warn("/material-dashboard/index.html resource was not found. This might happen if you're using a local (e.g., within-IDE) snapshot version... Try updating pom.xml to reference a released version of qfmd?");
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// If you have any assets to add to the web server (e.g., logos, icons) place them at //
|
// If you have any assets to add to the web server (e.g., logos, icons) place them at //
|
||||||
// src/main/resources/material-dashboard-overlay (or a directory of your choice //
|
// src/main/resources/material-dashboard-overlay (or a directory of your choice //
|
||||||
@ -108,7 +115,10 @@ public class QApplicationJavalinServer
|
|||||||
// material-dashboard directory, so in case the same file exists in both (e.g., //
|
// material-dashboard directory, so in case the same file exists in both (e.g., //
|
||||||
// favicon.png), the app-specific one will be used. //
|
// favicon.png), the app-specific one will be used. //
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
if(getClass().getResource("/material-dashboard-overlay") != null)
|
||||||
|
{
|
||||||
config.staticFiles.add("/material-dashboard-overlay");
|
config.staticFiles.add("/material-dashboard-overlay");
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
// tell javalin where to find material-dashboard static web assets //
|
// tell javalin where to find material-dashboard static web assets //
|
||||||
@ -128,7 +138,7 @@ public class QApplicationJavalinServer
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
QJavalinImplementation qJavalinImplementation = new QJavalinImplementation(qInstance);
|
QJavalinImplementation qJavalinImplementation = new QJavalinImplementation(qInstance, javalinMetaData);
|
||||||
config.router.apiBuilder(qJavalinImplementation.getRoutes());
|
config.router.apiBuilder(qJavalinImplementation.getRoutes());
|
||||||
}
|
}
|
||||||
catch(QInstanceValidationException e)
|
catch(QInstanceValidationException e)
|
||||||
@ -526,4 +536,35 @@ public class QApplicationJavalinServer
|
|||||||
return (this);
|
return (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Getter for javalinMetaData
|
||||||
|
*******************************************************************************/
|
||||||
|
public QJavalinMetaData getJavalinMetaData()
|
||||||
|
{
|
||||||
|
return (this.javalinMetaData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Setter for javalinMetaData
|
||||||
|
*******************************************************************************/
|
||||||
|
public void setJavalinMetaData(QJavalinMetaData javalinMetaData)
|
||||||
|
{
|
||||||
|
this.javalinMetaData = javalinMetaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Fluent setter for javalinMetaData
|
||||||
|
*******************************************************************************/
|
||||||
|
public QApplicationJavalinServer withJavalinMetaData(QJavalinMetaData javalinMetaData)
|
||||||
|
{
|
||||||
|
this.javalinMetaData = javalinMetaData;
|
||||||
|
return (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user