private Map findLoaders ( ) { Map loaders = getContainer ( ) . getComponentDescriptorMap ( ProviderLoader . class . getName ( ) ) ; if ( loaders == null ) { throw new Error ( "No provider loaders found" ) ; } Set keys = loaders . keySet ( ) ; Map found = null ; ProviderLoader defaultLoader = null ; for ( Iterator iter = keys . iterator ( ) ; iter . hasNext ( ) ; ) { String key = ( String ) iter . next ( ) ; ProviderLoader loader ; try { loader = ( ProviderLoader ) getContainer ( ) . lookup ( ProviderLoader . class . getName ( ) , key ) ; } catch ( Exception e ) { log . warn ( "Failed to lookup provider loader for key: {}" , key , e ) ; continue ; } if ( loader != null ) { if ( found == null ) { // we need an ordered map found = new LinkedHashMap ( ) ; } if ( key . equals ( SELECT_DEFAULT ) ) { defaultLoader = loader ; } else { found . put ( key , loader ) ; } } } // the default should be added at the end (as fallback) assert defaultLoader != null ; found . put ( SELECT_DEFAULT , defaultLoader ) ; return found ; }
Find any provider loaders which are available in the container .