protected Plugin readPluginFile ( PluginCoordinates coordinates , File pluginFile ) throws Exception { try { PluginClassLoader pluginClassLoader = createPluginClassLoader ( pluginFile ) ; URL specFile = pluginClassLoader . getResource ( PluginUtils . PLUGIN_SPEC_PATH ) ; if ( specFile == null ) { throw new Exception ( Messages . i18n . format ( "DefaultPluginRegistry.MissingPluginSpecFile" , PluginUtils . PLUGIN_SPEC_PATH ) ) ; //$NON-NLS-1$ } else { PluginSpec spec = PluginUtils . readPluginSpecFile ( specFile ) ; Plugin plugin = new Plugin ( spec , coordinates , pluginClassLoader ) ; // TODO use logger when available System . out . println ( "Read apiman plugin: " + spec ) ; //$NON-NLS-1$ return plugin ; } } catch ( Exception e ) { throw new Exception ( Messages . i18n . format ( "DefaultPluginRegistry.InvalidPlugin" , pluginFile . getAbsolutePath ( ) ) , e ) ; //$NON-NLS-1$ } }
Reads the plugin into an object . This method will fail if the plugin is not valid . This could happen if the file is not a java archive or if the plugin spec file is missing from the archive etc .