private void loadPlugins ( ) { // Read the plugin class names from well known resources try { Enumeration < URL > pluginResources = classLoader . get ( ) . getResources ( "META-INF/services/org.springsource.reloading.agent.Plugins" ) ; while ( pluginResources . hasMoreElements ( ) ) { URL pluginResource = pluginResources . nextElement ( ) ; if ( GlobalConfiguration . isRuntimeLogging && log . isLoggable ( Level . FINEST ) ) { log . finest ( "loadPlugins: TypeRegistry=" + this . toString ( ) + ": loading plugin list file " + pluginResource ) ; } InputStream is = pluginResource . openStream ( ) ; BufferedReader pluginClassNamesReader = new BufferedReader ( new InputStreamReader ( is ) ) ; try { while ( true ) { String pluginName = pluginClassNamesReader . readLine ( ) ; if ( pluginName == null ) { break ; } if ( ! pluginName . startsWith ( "#" ) ) { pluginClassNames . add ( pluginName ) ; } } } catch ( IOException ioe ) { // eof } is . close ( ) ; } } catch ( IOException e ) { // TODO Auto-generated catch block e . printStackTrace ( ) ; } // Now load those plugins for ( String pluginClassName : pluginClassNames ) { if ( GlobalConfiguration . isRuntimeLogging && log . isLoggable ( Level . FINEST ) ) { log . finest ( "loadPlugins: TypeRegistry=" + this . toString ( ) + ": loading plugin " + pluginClassName ) ; } try { Class < ? > pluginClass = Class . forName ( pluginClassName , false , this . classLoader . get ( ) ) ; Plugin pluginInstance = ( Plugin ) pluginClass . newInstance ( ) ; localPlugins . add ( pluginInstance ) ; } catch ( Exception e ) { log . log ( Level . WARNING , "Unable to find and instantiate plugin " + pluginClassName , e ) ; } } }
Determine if any plugins are visible from the attached classloader