org.apache.struts.beanvalidation.validation.interceptor

## Class DefaultBeanValidationManager

- java.lang.Object
- - org.apache.struts.beanvalidation.validation.interceptor.DefaultBeanValidationManager

- All Implemented Interfaces:
    BeanValidationManager

      public class DefaultBeanValidationManager
      extends Object
      implements BeanValidationManager

  This is the central class for javax.validation (JSR-303) in a Struts2 setup : It bootstraps a javax.validation.ValidationFactory and exposes it through the javax.validation.Validator interface. When talking to an instance of this bean we will 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. You need to pass provider class in order for this plugin to hook itself to underlying validation Factory. Any of following Validation provider can be provided using `struts.beanValidation.providerClass`

  - Hibernate Validator - `org.hibernate.validator.HibernateValidator`
  - Apache Bval - `org.apache.bval.jsr303.ApacheValidationProvider`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Class` | `providerClass`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultBeanValidationManager(String providerClassName, String ignoreXMLConfiguration, ObjectFactory objectFactory)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `javax.validation.Validator` | `getValidator()` Method to return Validator instance.This will take in to account the provider class will try to create a validation factory from given Validator.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### providerClass

          protected Class providerClass

  - ### Constructor Detail

    - #### DefaultBeanValidationManager

          public DefaultBeanValidationManager(String providerClassName,
                                              String ignoreXMLConfiguration,
                                              ObjectFactory objectFactory)

  - ### Method Detail

    - #### getValidator

          public javax.validation.Validator getValidator()

      Method to return Validator instance.This will take in to account the provider class will try to create a validation factory from given Validator. Validator will be returned based on the user preference.Validator will be created based on the following cases.

      In case user has specify explicitly and in a type safe fashion the expected provider, it will be used to create validation factory and an instance of javax.validation.Validator will be returned.

      In this case, the default validation provider resolver will be used to locate available providers. The chosen provider is defined as followed:

      - if the XML configuration defines a provider, this provider is used
      - if the XML configuration does not define a provider or if no XML configuration is present the first provider returned by the ValidationProviderResolver instance is used.
      Specified by:
        `getValidator` in interface `BeanValidationManager`
      Returns:
        validator instance

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.