Gentle refactor + track session number

This commit is contained in:
dotasek 2024-06-17 11:26:25 -04:00
parent fbf2d01069
commit 563d6fe27a
1 changed files with 23 additions and 18 deletions

View File

@ -489,6 +489,16 @@ public class ValidationService {
if (sessionId != null) {
System.out.println("No such cached session exists for session id " + sessionId + ", re-instantiating validator.");
}
ValidationEngine validationEngine = getValidationEngineFromCliContext(cliContext, definitions, tt);
sessionId = sessionCache.cacheSession(validationEngine);
System.out.println("Cached new session. Cache size = " + sessionCache.getSessionIds().size());
} else {
System.out.println("Cached session exists for session id " + sessionId + ", returning stored validator session id. Cache size = " + sessionCache.getSessionIds().size());
}
return sessionId;
}
private ValidationEngine getValidationEngineFromCliContext(CliContext cliContext, String definitions, TimeTracker tt) throws Exception {
ValidationEngine validationEngine;
if (cliContext.getBaseEngine() != null && hasBaseEngineForKey(cliContext.getBaseEngine())) {
System.out.println("Building new validator engine from base engine: " + cliContext.getBaseEngine());
@ -507,12 +517,7 @@ public class ValidationService {
}
validationEngine = buildValidationEngine(cliContext, definitions, tt);
}
sessionId = sessionCache.cacheSession(validationEngine);
System.out.println("Cached new session. Cache size = " + sessionCache.getSessionIds().size());
} else {
System.out.println("Cached session exists for session id " + sessionId + ", returning stored validator session id. Cache size = " + sessionCache.getSessionIds().size());
}
return sessionId;
return validationEngine;
}
protected ValidationEngine.ValidationEngineBuilder getValidationEngineBuilder() {