@ SuppressWarnings ( "rawtypes" ) private static PluginDefinition parsePluginDefinition ( final ClassLoader cl , final Element plugin ) throws PluginConfigurationException { // Check if the plugin definition is inside its own file if ( getAttributeValue ( plugin , "definedIn" , false ) != null ) { StreamManager sm = new StreamManager ( ) ; String sFileName = getAttributeValue ( plugin , "definedIn" , false ) ; try { InputStream in = sm . handle ( cl . getResourceAsStream ( sFileName ) ) ; return parseXmlPluginDefinition ( cl , in ) ; } finally { sm . closeAll ( ) ; } } String pluginClass = getAttributeValue ( plugin , "class" , true ) ; Class clazz ; try { clazz = LoadedClassCache . getClass ( cl , pluginClass ) ; if ( ! IPluginInterface . class . isAssignableFrom ( clazz ) ) { throw new PluginConfigurationException ( "Specified class '" + clazz . getName ( ) + "' in the plugin.xml file does not implement " + "the IPluginInterface interface" ) ; } if ( isAnnotated ( clazz ) ) { return loadFromPluginAnnotation ( clazz ) ; } } catch ( ClassNotFoundException e ) { throw new PluginConfigurationException ( e . getMessage ( ) , e ) ; } // The class is not annotated not has an external definition file... // Loading from current xml file... String sDescription = getAttributeValue ( plugin , "description" , false ) ; @ SuppressWarnings ( "unchecked" ) PluginDefinition pluginDef = new PluginDefinition ( getAttributeValue ( plugin , "name" , true ) , sDescription , clazz ) ; parseCommandLine ( pluginDef , plugin ) ; return pluginDef ; }
Parse an XML plugin definition .