public static HOTPProvider instantiateProvider ( boolean allowTestProvider ) { HOTPProvider resultProvider = null ; ServiceLoader < HOTPProvider > loader = ServiceLoader . load ( HOTPProvider . class ) ; Iterator < HOTPProvider > iterator = loader . iterator ( ) ; if ( iterator . hasNext ( ) ) { while ( iterator . hasNext ( ) ) { HOTPProvider provider = iterator . next ( ) ; if ( ! "com.payneteasy.superfly.spring.TestHOTPProvider" . equals ( provider . getClass ( ) . getName ( ) ) || allowTestProvider ) { resultProvider = provider ; break ; } } } return resultProvider ; }
Instantiates a provider using service loader .