/** * Create a new MethodValidationInterceptor using the given JSR-303 ValidatorFactory. * @param validatorFactory the JSR-303 ValidatorFactory to use */ public MethodValidationInterceptor(ValidatorFactory validatorFactory) { this(validatorFactory.getValidator()); }
/** * Set the JSR-303 ValidatorFactory to delegate to for validating methods, * using its default Validator. * <p>Default is the default ValidatorFactory's default Validator. * @see javax.validation.ValidatorFactory#getValidator() */ public void setValidatorFactory(ValidatorFactory validatorFactory) { this.validator = validatorFactory.getValidator(); }
/** * Set the JSR-303 ValidatorFactory to delegate to for validating beans, * using its default Validator. * <p>Default is the default ValidatorFactory's default Validator. * @see javax.validation.ValidatorFactory#getValidator() */ public void setValidatorFactory(ValidatorFactory validatorFactory) { this.validator = validatorFactory.getValidator(); }
@Override public void afterPropertiesSet() { if (this.validator == null) { this.validator = Validation.buildDefaultValidatorFactory().getValidator(); } }
@Override public Validator getValidator() { Assert.notNull(this.validatorFactory, "No target ValidatorFactory set"); return this.validatorFactory.getValidator(); }
/** * Set the JSR-303 ValidatorFactory to delegate to for validating methods, * using its default Validator. * <p>Default is the default ValidatorFactory's default Validator. * @see javax.validation.ValidatorFactory#getValidator() */ public void setValidatorFactory(ValidatorFactory validatorFactory) { this.validator = validatorFactory.getValidator(); }
/** * Create a new MethodValidationInterceptor using the given JSR-303 ValidatorFactory. * @param validatorFactory the JSR-303 ValidatorFactory to use */ public MethodValidationInterceptor(ValidatorFactory validatorFactory) { this(validatorFactory.getValidator()); }
/** * Set the JSR-303 ValidatorFactory to delegate to for validating beans, * using its default Validator. * <p>Default is the default ValidatorFactory's default Validator. * @see javax.validation.ValidatorFactory#getValidator() */ public void setValidatorFactory(ValidatorFactory validatorFactory) { this.validator = validatorFactory.getValidator(); }
@Override public Validator getValidator() { Assert.notNull(this.validatorFactory, "No target ValidatorFactory set"); return this.validatorFactory.getValidator(); }
@Override public void afterPropertiesSet() { if (this.validator == null) { this.validator = Validation.buildDefaultValidatorFactory().getValidator(); } }
public static Validator getValidator() { if (validator == null) { synchronized (BeanValidator.class) { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); return validator = factory.getValidator(); } } return validator; }
@Override public void configure(Binder binder) { binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator()); binder.bind(JsonConfigurator.class).in(LazySingleton.class); }
/** * Creates a new {@link Validator} based on {@link #newValidatorFactory()} */ public static Validator newValidator() { return newValidatorFactory().getValidator(); }
/** * Creates an environment and enables injecting validator feature. */ public Environment(String name, ObjectMapper objectMapper, ValidatorFactory validatorFactory, MetricRegistry metricRegistry, @Nullable ClassLoader classLoader, HealthCheckRegistry healthCheckRegistry) { this(name, objectMapper, validatorFactory.getValidator(), metricRegistry, classLoader, healthCheckRegistry); this.jerseyEnvironment.register(new InjectValidatorFeature(validatorFactory)); }
/** * Creates a new {@link Validator} based on {@link #newConfiguration()} */ public static Validator newValidator() { return newConfiguration().buildValidatorFactory().getValidator(); }
@Override public void configure(Binder binder) { binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator()); binder.bind(JsonConfigurator.class).in(LazySingleton.class); binder.bind(Properties.class).toInstance(props); } },
@SuppressWarnings({"unchecked", "rawtypes"}) public JValidator(URL url) { this.clazz = ReflectUtils.forName(url.getServiceInterface()); String jvalidation = url.getParameter("jvalidation"); ValidatorFactory factory; if (jvalidation != null && jvalidation.length() > 0) { factory = Validation.byProvider((Class) ReflectUtils.forName(jvalidation)).configure().buildValidatorFactory(); } else { factory = Validation.buildDefaultValidatorFactory(); } this.validator = factory.getValidator(); this.methodClassMap = new ConcurrentHashMap<String, Class>(); }
@SuppressWarnings({"unchecked", "rawtypes"}) public JValidator(URL url) { this.clazz = ReflectUtils.forName(url.getServiceInterface()); String jvalidation = url.getParameter("jvalidation"); ValidatorFactory factory; if (jvalidation != null && jvalidation.length() > 0) { factory = Validation.byProvider((Class) ReflectUtils.forName(jvalidation)).configure().buildValidatorFactory(); } else { factory = Validation.buildDefaultValidatorFactory(); } this.validator = factory.getValidator(); this.methodClassMap = new ConcurrentHashMap<String, Class>(); }
@Override public void configure(Binder binder) { binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator()); binder.bind(JsonConfigurator.class).in(LazySingleton.class); binder.bind(Properties.class).toInstance(props); } },
@Override public void configure(Binder binder) { Properties props = new Properties(); props.put("druid.emitter.composing.emitters", "[\"" + testEmitterType + "\"]"); binder.bind(Properties.class).toInstance(props); binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator()); binder.bind(Emitter.class).annotatedWith(Names.named(testEmitterType)).toInstance(emitter); } },