This section describes the metadata annotations and deployment descriptor entries that allow an application to obtain instances of the Bean Validation Validator and ValidatorFactory types.
Applications that need to use those interfaces can find appropriate objects by looking up the name java:comp/Validator for Validator and java:comp/ValidatorFactory for ValidatorFactory, or by requesting the injection of an object of the appropriate type via the Resource annotation. The authenticationType and shareable elements of the Resource annotation must not be specified.
@Resource ValidatorFactory validatorFactory;
@Resource Validator validator;
For Validator objects, the default validation context is used. This means that all such Validators will be equivalent to those obtained by first acquiring a ValidatorFactory and then invoking the getValidator method on it with no arguments. In other words, the following two code snippets are equivalent: