Gentle refactor + track session number
This commit is contained in:
parent
fbf2d01069
commit
563d6fe27a
|
@ -489,24 +489,7 @@ public class ValidationService {
|
|||
if (sessionId != null) {
|
||||
System.out.println("No such cached session exists for session id " + sessionId + ", re-instantiating validator.");
|
||||
}
|
||||
ValidationEngine validationEngine;
|
||||
if (cliContext.getBaseEngine() != null && hasBaseEngineForKey(cliContext.getBaseEngine())) {
|
||||
System.out.println("Building new validator engine from base engine: " + cliContext.getBaseEngine());
|
||||
validationEngine = new ValidationEngine(getBaseEngine(cliContext.getBaseEngine()));
|
||||
/* As a service, it wouldn't be efficient to have a base validation engine
|
||||
* for every language. So we just use the baseEngine and set the language
|
||||
* manually afterward.
|
||||
*/
|
||||
validationEngine.setLanguage(cliContext.getLang());
|
||||
validationEngine.setLocale(cliContext.getLocale());
|
||||
} else {
|
||||
System.out.println("Building new validator engine from CliContext");
|
||||
if (cliContext.getSv() == null) {
|
||||
String sv = determineVersion(cliContext);
|
||||
cliContext.setSv(sv);
|
||||
}
|
||||
validationEngine = buildValidationEngine(cliContext, definitions, tt);
|
||||
}
|
||||
ValidationEngine validationEngine = getValidationEngineFromCliContext(cliContext, definitions, tt);
|
||||
sessionId = sessionCache.cacheSession(validationEngine);
|
||||
System.out.println("Cached new session. Cache size = " + sessionCache.getSessionIds().size());
|
||||
} else {
|
||||
|
@ -515,6 +498,28 @@ public class ValidationService {
|
|||
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());
|
||||
validationEngine = new ValidationEngine(getBaseEngine(cliContext.getBaseEngine()));
|
||||
/* As a service, it wouldn't be efficient to have a base validation engine
|
||||
* for every language. So we just use the baseEngine and set the language
|
||||
* manually afterward.
|
||||
*/
|
||||
validationEngine.setLanguage(cliContext.getLang());
|
||||
validationEngine.setLocale(cliContext.getLocale());
|
||||
} else {
|
||||
System.out.println("Building new validator engine from CliContext");
|
||||
if (cliContext.getSv() == null) {
|
||||
String sv = determineVersion(cliContext);
|
||||
cliContext.setSv(sv);
|
||||
}
|
||||
validationEngine = buildValidationEngine(cliContext, definitions, tt);
|
||||
}
|
||||
return validationEngine;
|
||||
}
|
||||
|
||||
protected ValidationEngine.ValidationEngineBuilder getValidationEngineBuilder() {
|
||||
return new ValidationEngine.ValidationEngineBuilder();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue