|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.validation.Validation
public class Validation
This class is the entry point for Bean Validation. There are three ways to bootstrap it:
ValidatorFactory
.
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
In this case, the default validation provider resolver
will be used to locate available providers.
The chosen provider is defined as followed:
ValidationProviderResolver
instance is used.ValidationProviderResolver
. The chosen
ValidationProvider
is then determined in the same way
as in the default bootstrapping case (see above).
Configuration<?> configuration = Validation
.byDefaultProvider()
.providerResolver( new MyResolverStrategy() )
.configure();
ValidatorFactory factory = configuration.buildValidatorFactory();
ValidationProviderResolver
.
ACMEConfiguration configuration = Validation
.byProvider(ACMEProvider.class)
.providerResolver( new MyResolverStrategy() ) // optionally set the provider resolver
.configure();
ValidatorFactory factory = configuration.buildValidatorFactory();
ValidatorFactory
object built by the bootstrap process should be cached
and shared amongst Validator
consumers.
Constructor Summary | |
---|---|
Validation()
|
Method Summary | ||
---|---|---|
static ValidatorFactory |
buildDefaultValidatorFactory()
Build and return a ValidatorFactory instance based on the
default Bean Validation provider and following the XML configuration. |
|
static GenericBootstrap |
byDefaultProvider()
Build a Configuration . |
|
static
|
byProvider(java.lang.Class<U> providerType)
Build a Configuration for a particular provider implementation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Validation()
Method Detail |
---|
public static ValidatorFactory buildDefaultValidatorFactory()
ValidatorFactory
instance based on the
default Bean Validation provider and following the XML configuration.
The provider list is resolved using the default validation provider resolver
logic.
The code is semantically equivalent to
Validation.byDefaultProvider().configure().buildValidatorFactory()
ValidatorFactory
instance.
ValidationException
- if the ValidatorFactory cannot be builtpublic static GenericBootstrap byDefaultProvider()
Configuration
. The provider list is resolved
using the strategy provided to the bootstrap state.
Configuration<?> configuration = Validation .byDefaultProvider() .providerResolver( new MyResolverStrategy() ) .configure(); ValidatorFactory factory = configuration.buildValidatorFactory();The provider can be specified in the XML configuration. If the XML configuration does not exsist or if no provider is specified, the first available provider will be returned.
Configuration
compliant with the bootstrap state provided.public static <T extends Configuration<T>,U extends ValidationProvider<T>> ProviderSpecificBootstrap<T> byProvider(java.lang.Class<U> providerType)
Configuration
for a particular provider implementation.
Optionally overrides the provider resolution strategy used to determine the provider.
Used by applications targeting a specific provider programmatically.
ACMEConfiguration configuration = Validation.byProvider(ACMEProvider.class) .providerResolver( new MyResolverStrategy() ) .configure();, where
ACMEConfiguration
is the
Configuration
sub interface uniquely identifying the
ACME Bean Validation provider. and ACMEProvider
is the
ValidationProvider
implementation of the ACME provider.
providerType
- the ValidationProvider
implementation type
Configuration
sub interface implementation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2009, 2010, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.
Generated on 4-June-2010 04:34