avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/extension/src/java/org/apache/avalon/excalibur/extension Extension.java
Date Sat, 06 Apr 2002 04:49:50 GMT
donaldp     02/04/05 20:49:49

  Modified:    extension/src/java/org/apache/avalon/excalibur/extension
                        Extension.java
  Log:
  Allow retrival of optional dependencies aswell as required dependencies
  
  Revision  Changes    Path
  1.18      +52 -21    jakarta-avalon-excalibur/extension/src/java/org/apache/avalon/excalibur/extension/Extension.java
  
  Index: Extension.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/extension/src/java/org/apache/avalon/excalibur/extension/Extension.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Extension.java	6 Apr 2002 04:22:28 -0000	1.17
  +++ Extension.java	6 Apr 2002 04:49:49 -0000	1.18
  @@ -26,7 +26,7 @@
    *
    * @author <a href="mailto:craigmcc@apache.org">Craig R. McClanahan</a>
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.17 $ $Date: 2002/04/06 04:22:28 $
  + * @version $Revision: 1.18 $ $Date: 2002/04/06 04:49:49 $
    */
   public final class Extension
   {
  @@ -222,24 +222,20 @@
        */
       public static Extension[] getRequired( final Manifest manifest )
       {
  -        final ArrayList results = new ArrayList();
  -        final Attributes mainAttributes = manifest.getMainAttributes();
  -
  -        if( null != mainAttributes )
  -        {
  -            getRequired( mainAttributes, results );
  -        }
  -
  -        final Map entries = manifest.getEntries();
  -        final Iterator keys = entries.keySet().iterator();
  -        while( keys.hasNext() )
  -        {
  -            final String key = (String)keys.next();
  -            final Attributes attributes = (Attributes)entries.get( key );
  -            getRequired( attributes, results );
  -        }
  +        return getListed( manifest, EXTENSION_LIST );
  +    }
   
  -        return (Extension[])results.toArray( new Extension[ 0 ] );
  +    /**
  +     * Return the set of <code>Extension</code> objects representing "Optional
  +     * Packages" that the application declares they will use if present. If
  +     * there are no such optional packages, a zero-length list is returned.
  +     *
  +     * @param manifest Manifest to be parsed
  +     * @return the optional dependencies that are specified in manifest
  +     */
  +    public static Extension[] getOptions( final Manifest manifest )
  +    {
  +        return getListed( manifest, OPTIONAL_EXTENSION_LIST );
       }
   
       /**
  @@ -592,15 +588,50 @@
       }
   
       /**
  +     * Retrieve all the extensions listed under a particular key
  +     * (Usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST).
  +     *
  +     * @param manifest the manifest to extract extensions from
  +     * @param listKey the key used to get list (Usually
  +     *        EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)
  +     * @return the list of listed extensions
  +     */
  +    private static Extension[] getListed( final Manifest manifest,
  +                                          final Attributes.Name listKey )
  +    {
  +        final ArrayList results = new ArrayList();
  +        final Attributes mainAttributes = manifest.getMainAttributes();
  +
  +        if( null != mainAttributes )
  +        {
  +            getExtension( mainAttributes, results, listKey );
  +        }
  +
  +        final Map entries = manifest.getEntries();
  +        final Iterator keys = entries.keySet().iterator();
  +        while( keys.hasNext() )
  +        {
  +            final String key = (String)keys.next();
  +            final Attributes attributes = (Attributes)entries.get( key );
  +            getExtension( attributes, results, listKey );
  +        }
  +
  +        return (Extension[])results.toArray( new Extension[ 0 ] );
  +    }
  +
  +    /**
        * Add required optional packages defined in the specified attributes entry, if any.
        *
        * @param attributes Attributes to be parsed
        * @param required list to add required optional packages to
  +     * @param listKey the key to use to lookup list, usually EXTENSION_LIST
  +     *    or OPTIONAL_EXTENSION_LIST
        */
  -    private static void getRequired( final Attributes attributes,
  -                                     final ArrayList required )
  +    private static void getExtension( final Attributes attributes,
  +                                     final ArrayList required,
  +                                     final Attributes.Name listKey )
       {
  -        final String names = attributes.getValue( EXTENSION_LIST );
  +        final String names = attributes.getValue( listKey );
           if( null == names )
           {
               return;
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message