SpringWebConstraintValidatorFactory for use with validation.xml

Issue: SPR-13327
This commit is contained in:
Juergen Hoeller
2015-08-21 17:02:55 +02:00
parent 79e24aeced
commit 6d1b8b5a31
3 changed files with 77 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,11 @@ import org.springframework.util.Assert;
* JSR-303 {@link ConstraintValidatorFactory} implementation that delegates to a
* Spring BeanFactory for creating autowired {@link ConstraintValidator} instances.
*
* <p>Note that this class is meant for programmatic use, not for declarative use
* in a standard {@code validation.xml} file. Consider
* {@link org.springframework.web.bind.support.SpringWebConstraintValidatorFactory}
* for declarative use in a web application, e.g. with JAX-RS or JAX-WS.
*
* @author Juergen Hoeller
* @since 3.0
* @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean(Class)
@@ -51,6 +56,7 @@ public class SpringConstraintValidatorFactory implements ConstraintValidatorFact
return this.beanFactory.createBean(key);
}
// Bean Validation 1.1 releaseInstance method
public void releaseInstance(ConstraintValidator<?, ?> instance) {
this.beanFactory.destroyBean(instance);
}