public static < T > List < T > load ( ClassLoader classLoader , Class < T > serviceType ) { List < T > foundServices = new ArrayList <> ( ) ; Iterator < T > iterator = ServiceLoader . load ( serviceType , classLoader ) . iterator ( ) ; while ( checkHasNextSafely ( iterator ) ) { try { T item = iterator . next ( ) ; foundServices . add ( item ) ; LOGGER . debug ( String . format ( "Found %s [%s]" , serviceType . getSimpleName ( ) , item . toString ( ) ) ) ; } catch ( ServiceConfigurationError e ) { LOGGER . trace ( "Can't find services using Java SPI" , e ) ; LOGGER . error ( e . getMessage ( ) ) ; } } return foundServices ; }
Invoke to find all services for given service type using specified class loader