private ValidatorFactory createValidatorFactory ( FacesContext context ) { Map < String , Object > applicationMap = context . getExternalContext ( ) . getApplicationMap ( ) ; Object attr = applicationMap . get ( VALIDATOR_FACTORY_KEY ) ; if ( attr instanceof ValidatorFactory ) { return ( ValidatorFactory ) attr ; } else { synchronized ( this ) { if ( _ExternalSpecifications . isBeanValidationAvailable ( ) ) { ValidatorFactory factory = Validation . buildDefaultValidatorFactory ( ) ; applicationMap . put ( VALIDATOR_FACTORY_KEY , factory ) ; return factory ; } else { throw new FacesException ( "Bean Validation is not present" ) ; } } } }
This method creates ValidatorFactory instances or retrieves them from the container .