stash in a static field, the list set of topLevel classes (performance gain for setups where this class is called multiple times (along with clearing that cache during a javalin instance hotswap)

This commit is contained in:
2024-05-10 12:24:29 -05:00
parent 81a5d868b6
commit 196488ad6e
2 changed files with 41 additions and 3 deletions

View File

@ -103,6 +103,7 @@ import com.kingsrook.qqq.backend.core.model.actions.values.SearchPossibleValueSo
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetInput;
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetOutput;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.MetaDataProducerHelper;
import com.kingsrook.qqq.backend.core.model.metadata.QBackendMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.fields.AdornmentType;
@ -283,6 +284,14 @@ public class QJavalinImplementation
try
{
////////////////////////////////////////////////////////////////////////////////
// clear the cache of classes in this class, so that new classes can be found //
////////////////////////////////////////////////////////////////////////////////
MetaDataProducerHelper.clearTopLevelClassCache();
/////////////////////////////////////////////////
// try to get a new instance from the supplier //
/////////////////////////////////////////////////
QInstance newQInstance = qInstanceHotSwapSupplier.get();
if(newQInstance == null)
{
@ -290,6 +299,9 @@ public class QJavalinImplementation
return;
}
///////////////////////////////////////////////////////////////////////////////////
// validate the instance, and only if it passes, then set it in our static field //
///////////////////////////////////////////////////////////////////////////////////
new QInstanceValidator().validate(newQInstance);
QJavalinImplementation.qInstance = newQInstance;
LOG.info("Swapped qInstance");