private List < ValidationProvider < ? > > loadProviders ( ClassLoader classLoader ) { @ SuppressWarnings ( "rawtypes" ) Iterator < ValidationProvider > providerIterator = ServiceLoader . load ( ValidationProvider . class , classLoader ) . iterator ( ) ; LinkedList < ValidationProvider < ? > > providers = new LinkedList < ValidationProvider < ? > > ( ) ; while ( providerIterator . hasNext ( ) ) { try { ValidationProvider < ? > provider = providerIterator . next ( ) ; // put Hibernate Validator to the beginning of the list if ( provider . getClass ( ) . getName ( ) . equals ( "org.hibernate.validator.HibernateValidator" ) ) { providers . addFirst ( provider ) ; } else { providers . add ( provider ) ; } } catch ( ServiceConfigurationError e ) { // ignore, because it can happen when multiple // providers are present and some of them are not class loader // compatible with our API. } } return providers ; }
Retrieves the providers from the given loader using the service loader mechanism .