|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.validation.beanvalidation.SpringValidatorAdapter org.springframework.validation.beanvalidation.LocalValidatorFactoryBean
public class LocalValidatorFactoryBean
This is the central class for javax.validation
(JSR-303) setup
in a Spring application context: It bootstraps a javax.validation.ValidationFactory
and exposes it through the Spring Validator
interface
as well as through the JSR-303 Validator
interface and the
ValidatorFactory
interface itself.
When talking to an instance of this bean through the Spring or JSR-303 Validator interfaces,
you'll be talking to the default Validator of the underlying ValidatorFactory. This is very
convenient in that you don't have to perform yet another call on the factory, assuming that
you will almost always use the default Validator anyway. This can also be injected directly
into any target dependency of type Validator
!
ValidatorFactory
,
Validator
,
Validation.buildDefaultValidatorFactory()
,
ValidatorFactory.getValidator()
Constructor Summary | |
---|---|
LocalValidatorFactoryBean()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware). |
javax.validation.ConstraintValidatorFactory |
getConstraintValidatorFactory()
|
javax.validation.MessageInterpolator |
getMessageInterpolator()
|
javax.validation.TraversableResolver |
getTraversableResolver()
|
Map<String,String> |
getValidationPropertyMap()
Allow Map access to the bean validation properties to be passed to the validation provider, with the option to add or override specific entries. |
javax.validation.Validator |
getValidator()
|
void |
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in. |
void |
setConstraintValidatorFactory(javax.validation.ConstraintValidatorFactory constraintValidatorFactory)
Specify a custom ConstraintValidatorFactory to use for this ValidatorFactory. |
void |
setMappingLocations(Resource[] mappingLocations)
Specify resource locations to load XML constraint mapping files from, if any. |
void |
setMessageInterpolator(javax.validation.MessageInterpolator messageInterpolator)
Specify a custom MessageInterpolator to use for this ValidatorFactory and its exposed default Validator. |
void |
setProviderClass(Class<? extends javax.validation.spi.ValidationProvider> providerClass)
Specify the desired provider class, if any. |
void |
setTraversableResolver(javax.validation.TraversableResolver traversableResolver)
Specify a custom TraversableResolver to use for this ValidatorFactory and its exposed default Validator. |
void |
setValidationProperties(Properties jpaProperties)
Specify bean validation properties to be passed to the validation provider. |
void |
setValidationPropertyMap(Map<String,String> validationProperties)
Specify bean validation properties to be passed to the validation provider as a Map. |
javax.validation.ValidatorContext |
usingContext()
|
Methods inherited from class org.springframework.validation.beanvalidation.SpringValidatorAdapter |
---|
getArgumentsForConstraint, getConstraintsForClass, supports, unwrap, validate, validate, validateProperty, validateValue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.validation.ValidatorFactory |
---|
unwrap |
Constructor Detail |
---|
public LocalValidatorFactoryBean()
Method Detail |
---|
public void setProviderClass(Class<? extends javax.validation.spi.ValidationProvider> providerClass)
If not specified, JSR-303's default search mechanism will be used.
Validation.byProvider(Class)
,
Validation.byDefaultProvider()
public void setMessageInterpolator(javax.validation.MessageInterpolator messageInterpolator)
public void setTraversableResolver(javax.validation.TraversableResolver traversableResolver)
public void setConstraintValidatorFactory(javax.validation.ConstraintValidatorFactory constraintValidatorFactory)
Default is a SpringConstraintValidatorFactory
, delegating to the
containing ApplicationContext for creating autowired ConstraintValidator instances.
public void setMappingLocations(Resource[] mappingLocations)
public void setValidationProperties(Properties jpaProperties)
Can be populated with a String "value" (parsed via PropertiesEditor) or a "props" element in XML bean definitions.
Configuration.addProperty(String, String)
public void setValidationPropertyMap(Map<String,String> validationProperties)
Can be populated with a "map" or "props" element in XML bean definitions.
Configuration.addProperty(String, String)
public Map<String,String> getValidationPropertyMap()
Useful for specifying entries directly, for example via "validationPropertyMap[myKey]".
public void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAware
Invoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
and
MessageSourceAware
, if applicable.
setApplicationContext
in interface ApplicationContextAware
applicationContext
- the ApplicationContext object to be used by this objectBeanInitializationException
public void afterPropertiesSet()
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
public javax.validation.Validator getValidator()
getValidator
in interface javax.validation.ValidatorFactory
public javax.validation.ValidatorContext usingContext()
usingContext
in interface javax.validation.ValidatorFactory
public javax.validation.MessageInterpolator getMessageInterpolator()
getMessageInterpolator
in interface javax.validation.ValidatorFactory
public javax.validation.TraversableResolver getTraversableResolver()
getTraversableResolver
in interface javax.validation.ValidatorFactory
public javax.validation.ConstraintValidatorFactory getConstraintValidatorFactory()
getConstraintValidatorFactory
in interface javax.validation.ValidatorFactory
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |