donaldp     01/11/16 21:21:11

  Modified:    src/scratchpad/org/apache/avalon/excalibur/extension
                        DefaultPackageRepository.java
  Log:
  Remove getOptionalPackage() as the policy should be in package manager and 
not i
  n repository to determine which package satisfies extension best.
  
  Also made sure that anytime an optionalPackage is added that needToScan is 
set to false. Otherwise the test wouldn't pass because its Repository did not 
do any scanning.
  
  Revision  Changes    Path
  1.6       +21 -30    
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/extension/DefaultPackageRepository.java
  
  Index: DefaultPackageRepository.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/extension/DefaultPackageRepository.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultPackageRepository.java     2001/11/17 00:58:47     1.5
  +++ DefaultPackageRepository.java     2001/11/17 05:21:11     1.6
  @@ -23,7 +23,7 @@
    * a path to find the Optional Packages.</p>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
  - * @version $Revision: 1.5 $ $Date: 2001/11/17 00:58:47 $
  + * @version $Revision: 1.6 $ $Date: 2001/11/17 05:21:11 $
    * @see OptionalPackage
    * @see PackageRepository
    */
  @@ -32,12 +32,20 @@
   {
       private static final boolean DEBUG = false;
   
  -    ///Map between files and <code>OptionalPackage</code> objects.
  +    /**
  +     * Map between files and <code>OptionalPackage</code> objects.
  +     */
       private final HashMap    m_packages = new HashMap();
   
  -    ///The set of directories in which to look for Optional Packages
  +    /**
  +     * The set of directories in which to look for Optional Packages
  +     */
       private final File[]     m_path;
   
  +    /**
  +     * Flag set when it is necessary to scan paths to 
  +     * build "Optional Package" list
  +     */
       private boolean          m_needToScan;
   
       /**
  @@ -68,32 +76,6 @@
       }
   
       /**
  -     * Return the <code>OptionalPackage</code> that provides specified
  -     * <code>Extension</code>. It is expected that this 
<code>Extension</code>
  -     * object will be one retrieved via getLocalExtension() method. If the
  -     * specified <code>Extension</code> is not local then <code>null</code>
  -     * is returned.
  -     *
  -     * @param extension Description of the optional package
  -     * @see #isLocal()
  -     */
  -    public OptionalPackage getOptionalPackage( final Extension extension )
  -    {
  -        final OptionalPackage[] packages = getOptionalPackages( extension );
  -
  -        //If theres a candidate package then return it
  -        //else return null
  -        if( null != packages || 0 != packages.length )
  -        {
  -            return packages[ 0 ];
  -        }
  -        else
  -        {
  -            return null;
  -        }
  -    }
  -
  -    /**
        * Return all the <code>OptionalPackage</code>s that satisfy specified
        * <code>Extension</code>. It is expected that this 
<code>Extension</code>
        * object will be one retrieved via getLocalExtension() method. If the
  @@ -137,8 +119,16 @@
           return (OptionalPackage[])results.toArray( new OptionalPackage[ 0 ] 
);
       }
   
  -    private synchronized void scanPath()
  +    /**
  +     * Scan the path for this repository and reload all 
  +     * the "Optional Packages" found in the path.
  +     *
  +     */
  +    protected final synchronized void scanPath()
       {
  +        m_packages.clear();
  +        m_needToScan = false;
  +
           for( int i = 0; i < m_path.length; i++ )
           {
               scanDirectory( m_path[ i ] );
  @@ -192,6 +182,7 @@
        */
       protected final void addOptionalPackage( final OptionalPackage 
optionalPackage )
       {
  +        m_needToScan = false;
           final Extension extension = 
optionalPackage.getAvailableExtensions()[ 0 ];
           ArrayList candidates = (ArrayList)m_packages.get( 
extension.getExtensionName() );
           if( null == candidates )
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to