public static ArrayList < ConfigSource > getDiscoveredSources ( ClassLoader classloader ) { ArrayList < ConfigSource > sources = new ArrayList <> ( ) ; //load config sources using the service loader try { ServiceLoader < ConfigSource > sl = ServiceLoader . load ( ConfigSource . class , classloader ) ; for ( ConfigSource source : sl ) { sources . add ( source ) ; } } catch ( ServiceConfigurationError e ) { throw new ConfigException ( Tr . formatMessage ( tc , "unable.to.discover.config.sources.CWMCG0010E" , e ) , e ) ; } try { //load config source providers using the service loader ServiceLoader < ConfigSourceProvider > providerSL = ServiceLoader . load ( ConfigSourceProvider . class , classloader ) ; for ( ConfigSourceProvider provider : providerSL ) { for ( ConfigSource source : provider . getConfigSources ( classloader ) ) { sources . add ( source ) ; } } } catch ( ServiceConfigurationError e ) { throw new ConfigException ( Tr . formatMessage ( tc , "unable.to.discover.config.source.providers.CWMCG0011E" , e ) , e ) ; } return sources ; }
Get ConfigSources found using the ServiceLoader pattern - both directly as found ConfigSources and those found via found ConfigSourceProviders getConfigSources method .