|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Configuration<T extends Configuration<T>>
Receives configuration information, selects the appropriate Bean Validation provider and builds the appropriate ValidatorFactory.
Usage:Configuration> configuration = //provided by one of the Validation bootstrap methods ValidatorFactory = configuration .messageInterpolator( new CustomMessageInterpolator() ) .buildValidatorFactory();By default, the configuration information is retrieved from META-INF/validation.xml It is possible to override the configuration retrieved from the XML file by using one or more of the Configuration methods. The ValidationProviderResolver is specified at Configuration time (see
ValidationProvider
).
If none is explicitely requested, the default ValidationProviderResolver is used.
The provider is selected in the following way:
- if a specific Configuration subclass is requested programmatically using
Validation.byProvider(Class), find the first provider matching it
- if a specific Configuration subclass is defined in META-INF/validation.xml,
find the first provider matching it
- otherwise, use the first provider returned by the ValidationProviderResolver
Implementations are not meant to be thread-safe
Method Summary | |
---|---|
T |
addMapping(java.io.InputStream stream)
Add a stream describing constraint mapping in the Bean Validation XML format. |
T |
addProperty(java.lang.String name,
java.lang.String value)
Add a provider specific property. |
ValidatorFactory |
buildValidatorFactory()
Build a ValidatorFactory implementation. |
T |
constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
Defines the constraint validator factory. |
MessageInterpolator |
getDefaultMessageInterpolator()
Return an implementation of the MessageInterpolator interface following the default MessageInterpolator defined in the specification: - use the ValidationMessages resource bundle to load keys - use Locale.getDefault() |
T |
ignoreXmlConfiguration()
Ignore data from the META-INF/validation.xml file if this method is called. |
T |
messageInterpolator(MessageInterpolator interpolator)
Defines the message interpolator used. |
T |
traversableResolver(TraversableResolver resolver)
Defines the traversable resolver used. |
Method Detail |
---|
T ignoreXmlConfiguration()
this
following the chaining method pattern.T messageInterpolator(MessageInterpolator interpolator)
interpolator
- message interpolator implementation.
this
following the chaining method pattern.T traversableResolver(TraversableResolver resolver)
resolver
- traversable resolver implementation.
this
following the chaining method pattern.T constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
constraintValidatorFactory
- constraint factory inmplementation.
this
following the chaining method pattern.T addMapping(java.io.InputStream stream)
ValidatorFactory
has been built. The Bean Validation provider
must not close the stream.
stream
- XML mapping stream.
this
following the chaining method pattern.
java.lang.IllegalArgumentException
- if stream
is nullT addProperty(java.lang.String name, java.lang.String value)
ValidatorFactory factory = Validation.byProvider(ACMEConfiguration.class)
.configure()
.providerSpecificProperty(ACMEState.FAST)
.buildValidatorFactory();
This method is typically used by containers parsing META-INF/validation.xml
themselves and injecting the state to the Configuration object.
If a property with a given name is defined both via this method and in the
XML configuration, the value set programmatically has priority.
If null is passed as a value, the value defined in XML is used. If no value
is defined in XML, the property is considered unset.
name
- property name.value
- property value.
this
following the chaining method pattern.
java.lang.IllegalArgumentException
- if name
is nullMessageInterpolator getDefaultMessageInterpolator()
ValidatorFactory buildValidatorFactory()
ValidationException
- if the ValidatorFactory cannot be built
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |