org.springframework.validation.beanvalidation.MethodValidationPostProcessor Java Examples

The following examples show how to use org.springframework.validation.beanvalidation.MethodValidationPostProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MethodValidationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Bean
public static MethodValidationPostProcessor methodValidationPostProcessor(@Lazy Validator validator) {
	MethodValidationPostProcessor postProcessor = new MethodValidationPostProcessor();
	postProcessor.setValidator(validator);
	postProcessor.setProxyTargetClass(true);
	return postProcessor;
}
 
Example #2
Source File: MethodValidationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testMethodValidationPostProcessor() {
	StaticApplicationContext ac = new StaticApplicationContext();
	ac.registerSingleton("mvpp", MethodValidationPostProcessor.class);
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("beforeExistingAdvisors", false);
	ac.registerSingleton("aapp", AsyncAnnotationBeanPostProcessor.class, pvs);
	ac.registerSingleton("bean", MyValidBean.class);
	ac.refresh();
	doTestProxyValidation(ac.getBean("bean", MyValidInterface.class));
	ac.close();
}
 
Example #3
Source File: ScheduledAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test(expected = BeanCreationException.class)
public void cronTaskWithMethodValidation() throws InterruptedException {
	BeanDefinition validationDefinition = new RootBeanDefinition(MethodValidationPostProcessor.class);
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(CronTestBean.class);
	context.registerBeanDefinition("methodValidation", validationDefinition);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();
}
 
Example #4
Source File: ScheduledAnnotationBeanPostProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test(expected = BeanCreationException.class)
public void cronTaskWithMethodValidation() {
	BeanDefinition validationDefinition = new RootBeanDefinition(MethodValidationPostProcessor.class);
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(CronTestBean.class);
	context.registerBeanDefinition("methodValidation", validationDefinition);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();
}
 
Example #5
Source File: ValidatorConfig.java    From spring-boot-vue-admin with Apache License 2.0 5 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
  final MethodValidationPostProcessor postProcessor = new MethodValidationPostProcessor();
  // 设置 validator 模式为快速失败返回
  postProcessor.setValidator(this.validatorFailFast());
  return postProcessor;
  // 默认是普通模式,会返回所有的验证不通过信息集合
  // return new MethodValidationPostProcessor();
}
 
Example #6
Source File: MethodValidationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testMethodValidationPostProcessor() {
	StaticApplicationContext ac = new StaticApplicationContext();
	ac.registerSingleton("mvpp", MethodValidationPostProcessor.class);
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("beforeExistingAdvisors", false);
	ac.registerSingleton("aapp", AsyncAnnotationBeanPostProcessor.class, pvs);
	ac.registerSingleton("bean", MyValidBean.class);
	ac.refresh();
	doTestProxyValidation(ac.getBean("bean", MyValidInterface.class));
	ac.close();
}
 
Example #7
Source File: ScheduledAnnotationBeanPostProcessorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test(expected = BeanCreationException.class)
public void cronTaskWithMethodValidation() {
	BeanDefinition validationDefinition = new RootBeanDefinition(MethodValidationPostProcessor.class);
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(CronTestBean.class);
	context.registerBeanDefinition("methodValidation", validationDefinition);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();
}
 
Example #8
Source File: ValidatorConfig.java    From Milkomeda with MIT License 5 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    MethodValidationPostProcessor postProcessor = new MethodValidationPostProcessor();
    // 设置validator模式为快速失败返回
    postProcessor.setValidator(validator());
    return postProcessor;
}
 
Example #9
Source File: MethodValidationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Bean
public static MethodValidationPostProcessor methodValidationPostProcessor(@Lazy Validator validator) {
	MethodValidationPostProcessor postProcessor = new MethodValidationPostProcessor();
	postProcessor.setValidator(validator);
	postProcessor.setProxyTargetClass(true);
	return postProcessor;
}
 
Example #10
Source File: MethodValidationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testMethodValidationPostProcessor() {
	StaticApplicationContext ac = new StaticApplicationContext();
	ac.registerSingleton("mvpp", MethodValidationPostProcessor.class);
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("beforeExistingAdvisors", false);
	ac.registerSingleton("aapp", AsyncAnnotationBeanPostProcessor.class, pvs);
	ac.registerSingleton("bean", MyValidBean.class);
	ac.refresh();
	doTestProxyValidation(ac.getBean("bean", MyValidInterface.class));
	ac.close();
}
 
Example #11
Source File: ValidationAutoConfigurationTest.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * The auto configuration creates the expected beans.
 */
@Test
public void expectedBeansExist() {
    this.contextRunner.run(
        context -> {
            Assertions.assertThat(context).hasSingleBean(MethodValidationPostProcessor.class);
            Assertions.assertThat(context).hasSingleBean(Validator.class);
            Assertions.assertThat(context).hasSingleBean(LocalValidatorFactoryBean.class);
        }
    );
}
 
Example #12
Source File: ClientWebConfigJava.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #13
Source File: ClientWebConfigJava.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #14
Source File: WebConfiguration.java    From spring-cloud-dashboard with Apache License 2.0 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
	return new MethodValidationPostProcessor();
}
 
Example #15
Source File: MethodValidationConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #16
Source File: ExampleApplication.java    From blog-examples with Apache License 2.0 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #17
Source File: CxfPropertiesTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #18
Source File: ValidationAutoConfiguration.java    From genie with Apache License 2.0 4 votes vote down vote up
/**
 * Setup method parameter bean validation.
 *
 * @return The method validation processor
 */
@Bean
@ConditionalOnMissingBean(MethodValidationPostProcessor.class)
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #19
Source File: LightminServerFeConfiguration.java    From spring-batch-lightmin with Apache License 2.0 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #20
Source File: TestDependencies.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
	return new MethodValidationPostProcessor();
}
 
Example #21
Source File: MethodValidationConfig.java    From spring-boot-cookbook with Apache License 2.0 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #22
Source File: GlobalExceptionHandler.java    From short-url with Apache License 2.0 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #23
Source File: TestDependencies.java    From spring-cloud-dashboard with Apache License 2.0 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
	return new MethodValidationPostProcessor();
}
 
Example #24
Source File: WebConfig.java    From imooc-security with Apache License 2.0 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor mvp(){
    return new MethodValidationPostProcessor();
}
 
Example #25
Source File: Application.java    From ic with MIT License 4 votes vote down vote up
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
 
Example #26
Source File: MethodValidationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public static MethodValidationPostProcessor methodValidationPostProcessor(@Lazy Validator validator) {
	MethodValidationPostProcessor postProcessor = new MethodValidationPostProcessor();
	postProcessor.setValidator(validator);
	return postProcessor;
}
 
Example #27
Source File: AnnotationDrivenEventListenerTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void conditionMatchWithProxy() {
	validateConditionMatch(ConditionalEventListener.class, MethodValidationPostProcessor.class);
}
 
Example #28
Source File: MethodValidationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Bean
public static MethodValidationPostProcessor methodValidationPostProcessor(@Lazy Validator validator) {
	MethodValidationPostProcessor postProcessor = new MethodValidationPostProcessor();
	postProcessor.setValidator(validator);
	return postProcessor;
}
 
Example #29
Source File: AnnotationDrivenEventListenerTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void conditionMatchWithProxy() {
	validateConditionMatch(ConditionalEventListener.class, MethodValidationPostProcessor.class);
}
 
Example #30
Source File: RepositoryApplicationConfiguration.java    From hawkbit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Defines the validation processor bean.
 *
 * @return the {@link MethodValidationPostProcessor}
 */
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}