Package org.springframework.web.bind.support

# Class SpringWebConstraintValidatorFactory

java.lang.Object
org.springframework.web.bind.support.SpringWebConstraintValidatorFactory

All Implemented Interfaces:
  `ConstraintValidatorFactory`

public class SpringWebConstraintValidatorFactory extends Object implements ConstraintValidatorFactory
JSR-303 `ConstraintValidatorFactory` implementation that delegates to the current Spring `WebApplicationContext` for creating autowired `ConstraintValidator` instances.

In contrast to `SpringConstraintValidatorFactory`, this variant is meant for declarative use in a standard `validation.xml` file, for example, in combination with JAX-RS or JAX-WS.

Since:
  4.2.1
Author:
  Juergen Hoeller
See Also:
  - `ContextLoader.getCurrentWebApplicationContext()`
  - `SpringConstraintValidatorFactory`

## Constructor Summary

Constructors
Constructor
Description
`SpringWebConstraintValidatorFactory()`

## Method Summary

Modifier and Type
Method
Description
`<T extends ConstraintValidator<?, ?>>
T`
`getInstance(Class<T> key)`
`protected WebApplicationContext`
`getWebApplicationContext()`
Retrieve the Spring `WebApplicationContext` to use.
`void`
`releaseInstance(ConstraintValidator<?,?> instance)`

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

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

## Constructor Details

### SpringWebConstraintValidatorFactory

public SpringWebConstraintValidatorFactory()

## Method Details

### getInstance

public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T> key)

Specified by:
  `getInstance` in interface `ConstraintValidatorFactory`

### releaseInstance

public void releaseInstance(ConstraintValidator<?,?> instance)

Specified by:
  `releaseInstance` in interface `ConstraintValidatorFactory`

### getWebApplicationContext

protected WebApplicationContext getWebApplicationContext()
Retrieve the Spring `WebApplicationContext` to use. The default implementation returns the current `WebApplicationContext` as registered for the thread context class loader.

Returns:
  the current WebApplicationContext (never `null`)
See Also:
  - `ContextLoader.getCurrentWebApplicationContext()`