public Validator getValidator(ValidatorConfig cfg) { String className = lookupRegisteredValidatorType(cfg.getType()); Validator validator; try { // instantiate the validator, and set configured parameters //todo - can this use the ThreadLocal? validator = objectFactory.buildValidator(className, cfg.getParams(), ActionContext.getContext().getContextMap()); } catch (Exception e) { final String msg = "There was a problem creating a Validator of type " + className + " : caused by " + e.getMessage(); throw new XWorkException(msg, e, cfg); } // set other configured properties validator.setMessageKey(cfg.getMessageKey()); validator.setDefaultMessage(cfg.getDefaultMessage()); validator.setMessageParameters(cfg.getMessageParams()); if (validator instanceof ShortCircuitableValidator) { ((ShortCircuitableValidator) validator).setShortCircuit(cfg.isShortCircuit()); } return validator; }