avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbenn...@apache.org
Subject cvs commit: avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl DefaultClassLoaderModel.java DefaultFilesetModel.java DirectoryScanner.java
Date Wed, 21 Apr 2004 03:21:04 GMT
tbennett    2004/04/20 20:21:04

  Modified:    composition/impl/src/java/org/apache/avalon/composition/model/impl
                        DefaultClassLoaderModel.java
                        DefaultFilesetModel.java DirectoryScanner.java
  Log:
  getting close on a final fileset implementation
  
  Revision  Changes    Path
  1.18      +2 -1      avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java
  
  Index: DefaultClassLoaderModel.java
  ===================================================================
  RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DefaultClassLoaderModel.java	20 Apr 2004 00:03:32 -0000	1.17
  +++ DefaultClassLoaderModel.java	21 Apr 2004 03:21:04 -0000	1.18
  @@ -656,6 +656,7 @@
           for( int i=0; i<filesets.length; i++ )
           {
               FilesetDirective fileset = filesets[i];
  +            getLocalLogger().debug("fileset.base=[" + fileset.getBaseDirectory() + "]");
               File anchor = getDirectory( base, fileset.getBaseDirectory() );
               getLocalLogger().debug("anchor=[" + anchor + "]");
   
  
  
  
  1.3       +21 -5     avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultFilesetModel.java
  
  Index: DefaultFilesetModel.java
  ===================================================================
  RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultFilesetModel.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultFilesetModel.java	20 Apr 2004 00:03:32 -0000	1.2
  +++ DefaultFilesetModel.java	21 Apr 2004 03:21:04 -0000	1.3
  @@ -142,8 +142,9 @@
        */
       public void setDefaultIncludes(String[] defaultIncludes) {
           if (defaultIncludes == null) {
  -            m_defaultIncludes = new String[1];
  -            m_defaultIncludes[0] = "*.jar";
  +            //m_defaultIncludes = new String[1];
  +            //m_defaultIncludes[0] = "*.jar";
  +            m_defaultIncludes = new String[0];
           } else {
               m_defaultIncludes = defaultIncludes;
           }
  @@ -182,10 +183,16 @@
        * to include in the classpath.
        */
       public void resolveFileset() throws IOException, IllegalStateException {
  -/*        
   
           // New stuff...
  +        if ( m_includes.length == 0 && m_defaultIncludes.length == 0 ) {
  +            m_list.add( m_anchor );
  +            m_logger.debug("candidates=[" + m_anchor + "]");
  +            return;
  +        }
  +        
           DirectoryScanner ds = new DirectoryScanner();
  +        ds.setLogger(m_logger);
   
           // Supply the directory scanner with our base directory anchor
           ds.setBasedir( m_anchor );
  @@ -194,6 +201,7 @@
           // Any default excludes to add?
           for (int i = 0; i < m_defaultExcludes.length; i++ )
           {
  +            m_logger.debug("m_defaultExcludes[" + i + "]=[" + m_defaultExcludes[i] + "]");
               ds.addDefaultExclude( m_defaultExcludes[i] );
           }
   
  @@ -207,6 +215,7 @@
               for (int i = 0; i < m_defaultIncludes.length; i++)
               {
                   includes[i] = m_defaultIncludes[i];
  +                m_logger.debug("includes[" + i + "]=[" + includes[i] + "]");
               }
           }
           else
  @@ -214,6 +223,7 @@
               for (int i = 0; i < m_includes.length; i++ )
               {
                   includes[i] = m_includes[i].getPath();
  +                m_logger.debug("includes[" + i + "]=[" + includes[i] + "]");
               }
           }
           ds.setIncludes( includes );
  @@ -223,6 +233,7 @@
           for (int i = 0; i < m_excludes.length; i++ )
           {
               excludes[i] = m_excludes[i].getPath();
  +            m_logger.debug("excludes[" + i + "]=[" + excludes[i] + "]");
           }
           ds.setExcludes( excludes );
   
  @@ -238,20 +249,25 @@
           if ( candidates.length > 0 ) {
               for (int i = 0; i < candidates.length; i++) {
                   File file = new File( m_anchor, candidates[i] );
  +                m_logger.debug("candidates[" + i + "]=[" + file.getAbsolutePath() + "]");
                   m_list.add( file );
               }
           } else {
               m_list.add( m_anchor );
  +            m_logger.debug("candidates=[" + m_anchor + "]");
           }
  -*/
  +/*        
           // Original stuff...
           if( m_includes.length > 0 ) {
               for( int j=0; j<m_includes.length; j++ ) {
                   File file = new File( m_anchor, m_includes[j].getPath() );
  +                m_logger.debug("candidates[" + j + "]=[" + file.getAbsolutePath() + "]");
                   m_list.add( file );
               }
           } else {
               m_list.add( m_anchor );
  +            m_logger.debug("candidates=[" + m_anchor + "]");
           }
  +*/
       }
   }
  
  
  
  1.5       +49 -2     avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DirectoryScanner.java
  
  Index: DirectoryScanner.java
  ===================================================================
  RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DirectoryScanner.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DirectoryScanner.java	20 Apr 2004 00:03:32 -0000	1.4
  +++ DirectoryScanner.java	21 Apr 2004 03:21:04 -0000	1.5
  @@ -31,6 +31,7 @@
   import org.apache.avalon.composition.model.FileSelector;
   import org.apache.avalon.composition.util.FileUtils;
   import org.apache.avalon.composition.util.ScannerUtils;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.util.env.Env;
   
   /**
  @@ -164,6 +165,11 @@
       protected boolean everythingIncluded = true;
   
       /**
  +     * Container-supplied logger instance.
  +     */
  +    private Logger m_logger;
  +    
  +    /**
        * Sole constructor.
        */
       public DirectoryScanner() {
  @@ -523,7 +529,7 @@
           if (includes == null) {
               // No includes supplied, so set it to 'matches all'
               includes = new String[1];
  -            includes[0] = "**//*.jar";
  +            includes[0] = "*.jar";
           }
           if (excludes == null) {
               excludes = new String[0];
  @@ -573,6 +579,8 @@
               String newpattern =
                   ScannerUtils.rtrimWildcardTokens(includes[icounter]);
               newroots.put(newpattern, includes[icounter]);
  +            getLogger().debug("newpattern=[" + newpattern + "]; " +
  +                    "includes[" + icounter + "]=[" + includes[icounter] + "]");
           }
   
           if (newroots.containsKey("")) {
  @@ -585,11 +593,15 @@
   
               File canonBase = null;
               canonBase = basedir.getCanonicalFile();
  +            getLogger().debug("canonBase=[" + canonBase + "]");
   
               while (enum2.hasMoreElements()) {
                   String currentelement = (String) enum2.nextElement();
  +                getLogger().debug("currentelement=[" + currentelement + "]");
                   String originalpattern = (String) newroots.get(currentelement);
  +                getLogger().debug("originalpattern=[" + originalpattern + "]");
                   File myfile = new File(basedir, currentelement);
  +                getLogger().debug("myfile=[" + myfile.getAbsolutePath() + "]");
   
                   if (myfile.exists()) {
                       // may be on a case insensitive file system.  We want
  @@ -626,8 +638,11 @@
                       }
   
                       if (myfile.isDirectory()) {
  +                        getLogger().debug("file is a directory!");
                           if (isIncluded(currentelement)
                               && currentelement.length() > 0) {
  +                            getLogger().debug("calling accounForIncludedDir(" +
  +                                    currentelement + "," + myfile.getAbsolutePath() + ")");
                               accountForIncludedDir(currentelement, myfile, true);
                           }  else {
                               if (currentelement.length() > 0) {
  @@ -638,6 +653,9 @@
                                           currentelement + File.separatorChar;
                                   }
                               }
  +                            getLogger().debug("calling scandir(" +
  +                                    myfile.getAbsolutePath() + "," +
  +                                    currentelement + ")");
                               scandir(myfile, currentelement, true);
                           }
                       } else {
  @@ -678,6 +696,8 @@
       protected void scandir(File dir, String vpath, boolean fast)
           throws IOException
       {
  +        getLogger().debug("Inside scandir");
  +        
           if (dir == null) {
               throw new IOException("dir must not be null.");
           } else if (!dir.exists()) {
  @@ -734,10 +754,14 @@
           for (int i = 0; i < newfiles.length; i++) {
               String name = vpath + newfiles[i];
               File   file = new File(dir, newfiles[i]);
  +            getLogger().debug("file=[" + file.getAbsolutePath() + "]");
               if (file.isDirectory()) {
  +                getLogger().debug("this is a directory.");
                   if (isIncluded(name)) {
  +                    getLogger().debug("and it will be included");
                       accountForIncludedDir(name, file, fast);
                   } else {
  +                    getLogger().debug("and it will not be included");
                       everythingIncluded = false;
                       dirsNotIncluded.addElement(name);
                       if (fast && couldHoldIncluded(name)) {
  @@ -748,9 +772,12 @@
                       scandir(file, name + File.separator, fast);
                   }
               } else if (file.isFile()) {
  +                getLogger().debug("this is a file");
                   if (isIncluded(name)) {
  +                    getLogger().debug("and it will be included");
                       accountForIncludedFile(name, file);
                   } else {
  +                    getLogger().debug("and it will not be included");
                       everythingIncluded = false;
                       filesNotIncluded.addElement(name);
                   }
  @@ -792,28 +819,40 @@
       private void accountForIncludedDir(String name, File file, boolean fast) 
           throws IOException
       {
  +        getLogger().debug("Inside accountForIncludeDir");
  +        
           if (!dirsIncluded.contains(name)
               && !dirsExcluded.contains(name)
               && !dirsDeselected.contains(name)) {
   
  +            getLogger().debug("waypoint-1");
               if (!isExcluded(name)) {
  +                getLogger().debug("waypoint-2a");
                   if (isSelected(name, file)) {
  +                    getLogger().debug("waypoint-3a");
                       dirsIncluded.addElement(name);
                       if (fast) {
  +                        getLogger().debug("calling scandir(" +
  +                                file.getAbsolutePath() + "," +
  +                                name + File.separator);
                           scandir(file, name + File.separator, fast);
                       }
                   } else {
  +                    getLogger().debug("waypoint-3b");
                       everythingIncluded = false;
                       dirsDeselected.addElement(name);
                       if (fast && couldHoldIncluded(name)) {
  +                        getLogger().debug("waypoint-4b");
                           scandir(file, name + File.separator, fast);
                       }
                   }
   
               } else {
  +                getLogger().debug("waypoint-2b");
                   everythingIncluded = false;
                   dirsExcluded.addElement(name);
                   if (fast && couldHoldIncluded(name)) {
  +                    getLogger().debug("waypoint-3c");
                       scandir(file, name + File.separator, fast);
                   }
               }
  @@ -1131,6 +1170,14 @@
           }
           buffer.append(")}");
           return buffer.toString();
  +    }
  +
  +    public Logger getLogger() {
  +        return m_logger;
  +    }
  +    
  +    public void setLogger(Logger logger) {
  +        m_logger = logger;
       }
    
   }
  
  
  

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


Mime
View raw message