Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.validation.beanvalidation
Class MethodValidationInterceptor

    java.lang.Object
      org.springframework.validation.beanvalidation.MethodValidationInterceptor

All Implemented Interfaces:
  org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor

    public class MethodValidationInterceptor

extends java.lang.Object
implements org.aopalliance.intercept.MethodInterceptor

An AOP Alliance `MethodInterceptor` implementation that delegates to a JSR-303 provider for performing method-level validation on annotated methods.

Applicable methods have JSR-303 constraint annotations on their parameters and/or on their return value (in the latter case specified at the method level, typically as inline annotation).

E.g.: `public @NotNull Object myValidMethod(@NotNull String arg1, @Max(10) int arg2)`

Validation groups can be specified through Spring's `Validated` annotation at the type level of the containing target class, applying to all public service methods of that class. By default, JSR-303 will validate against its default group only.

As of Spring 3.1, this functionality requires Hibernate Validator 4.2 or higher. In Spring 3.2, this class will autodetect a Bean Validation 1.1 compliant provider and automatically use the standard method validation support there (once available).

Since:
  3.1
Author:
  Juergen Hoeller
See Also:
  `MethodValidationPostProcessor`, `MethodValidator`

Constructor Summary
`MethodValidationInterceptor()` Create a new MethodValidationInterceptor using a default JSR-303 validator underneath.
`MethodValidationInterceptor(javax.validation.Validator validator)` Create a new MethodValidationInterceptor using the given JSR-303 Validator.
`MethodValidationInterceptor(javax.validation.ValidatorFactory validatorFactory)` Create a new MethodValidationInterceptor using the given JSR-303 ValidatorFactory.

Method Summary
`protected java.lang.Class[]` | `determineValidationGroups(org.aopalliance.intercept.MethodInvocation invocation)` Determine the validation groups to validate against for the given method invocation.
`java.lang.Object` | `invoke(org.aopalliance.intercept.MethodInvocation invocation)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MethodValidationInterceptor

    public MethodValidationInterceptor()

  Create a new MethodValidationInterceptor using a default JSR-303 validator underneath.

### MethodValidationInterceptor

    public MethodValidationInterceptor(javax.validation.ValidatorFactory validatorFactory)

  Create a new MethodValidationInterceptor using the given JSR-303 ValidatorFactory.

  Parameters:
    `validatorFactory` - the JSR-303 ValidatorFactory to use

### MethodValidationInterceptor

    public MethodValidationInterceptor(javax.validation.Validator validator)

  Create a new MethodValidationInterceptor using the given JSR-303 Validator.

  Parameters:
    `validator` - the JSR-303 Validator to use

Method Detail

### invoke

    public java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
                            throws java.lang.Throwable

  Specified by:
    `invoke` in interface `org.aopalliance.intercept.MethodInterceptor`
  Throws:
    `java.lang.Throwable`

### determineValidationGroups

    protected java.lang.Class[] determineValidationGroups(org.aopalliance.intercept.MethodInvocation invocation)

  Determine the validation groups to validate against for the given method invocation.

  Default are the validation groups as specified in the `Validated` annotation on the containing target class of the method.

  Parameters:
    `invocation` - the current MethodInvocation
  Returns:
    the applicable validation groups as a Class array

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD