You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by br...@apache.org on 2010/03/02 12:42:15 UTC
svn commit: r917976 [1/2] - in /archiva/sandbox/archiva-scanner-performance:
./ src/ src/main/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/archiva/
Author: brett
Date: Tue Mar 2 11:42:14 2010
New Revision: 917976
URL: http://svn.apache.org/viewvc?rev=917976&view=rev
Log:
[MRM-589] add some tests for directory walkers
The DirectoryWalker and DirectoryWalkListener classes are from plexus-utils r3632 by Joakim Erdfelt and are under the Apache License 2.0.
The TokenizedPattern and SelectorUtils classes are from Ant 1.8.0.
Added:
archiva/sandbox/archiva-scanner-performance/ (with props)
archiva/sandbox/archiva-scanner-performance/pom.xml (with props)
archiva/sandbox/archiva-scanner-performance/src/
archiva/sandbox/archiva-scanner-performance/src/main/
archiva/sandbox/archiva-scanner-performance/src/main/java/
archiva/sandbox/archiva-scanner-performance/src/main/java/org/
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java (with props)
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalkListener.java (with props)
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalker.java (with props)
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/FileUtils.java
- copied, changed from r917946, ant/core/tags/ANT_180/src/main/org/apache/tools/ant/util/FileUtils.java
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/SelectorUtils.java
- copied, changed from r917944, ant/core/tags/ANT_180/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/TokenizedPattern.java
- copied, changed from r917944, ant/core/tags/ANT_180/src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java
Propchange: archiva/sandbox/archiva-scanner-performance/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Mar 2 11:42:14 2010
@@ -0,0 +1,2 @@
+archiva-scanner-performance.iml
+target
Added: archiva/sandbox/archiva-scanner-performance/pom.xml
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-scanner-performance/pom.xml?rev=917976&view=auto
==============================================================================
--- archiva/sandbox/archiva-scanner-performance/pom.xml (added)
+++ archiva/sandbox/archiva-scanner-performance/pom.xml Tue Mar 2 11:42:14 2010
@@ -0,0 +1,55 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-scanner-performance</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>archiva-scanner-performance</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.5.6</version>
+ <scope>runtime</scope>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.8.0</version>
+ </dependency>-->
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>test-current-implementation</id>
+ <activation>
+ <property>
+ <name>!test13</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-scanner</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>test-previous-implementation</id>
+ <activation>
+ <property>
+ <name>test13</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-layer</artifactId>
+ <version>1.3</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+</project>
Propchange: archiva/sandbox/archiva-scanner-performance/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java?rev=917976&view=auto
==============================================================================
--- archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java (added)
+++ archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java Tue Mar 2 11:42:14 2010
@@ -0,0 +1,278 @@
+package org.apache.archiva;
+
+import org.apache.archiva.repository.scanner.DefaultRepositoryScanner;
+import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
+import org.apache.archiva.repository.scanner.RepositoryScanner;
+import org.apache.archiva.repository.scanner.RepositoryScannerException;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Hello world!
+ */
+public class App
+{
+ private static final List<String> EXCLUDES = Arrays.asList( RepositoryScanner.IGNORABLE_CONTENT );
+
+ private static final Runtime RUNTIME = Runtime.getRuntime();
+
+ public static void main( String[] args )
+ throws RepositoryScannerException, IOException, InterruptedException
+ {
+ File basedir = args.length > 0 ? new File( args[0] ) : new File( System.getProperty( "user.home" ),
+ "Library/Application Support/Archiva/data/repositories/internal" );
+
+ gc();
+// System.out.println( "ant scanner" );
+// scanUsingAntScanner( basedir );
+ System.out.println( "plexus-utils walker" );
+ scanUsingUtilsWalker( basedir );
+ System.out.println( "new walker" );
+ scanUsingNewWalker( basedir );
+ System.out.println( "commons-io walker" );
+ scanUsingCommonsWalker( basedir );
+ System.out.println( "Current repository scanner" );
+ scanUsingRepositoryScanner( basedir );
+ System.out.println( "plexus-utils scanner" );
+ scanUsingUtilsScanner( basedir );
+ }
+
+ private static void scanUsingCommonsWalker( File basedir )
+ throws IOException, InterruptedException
+ {
+ long startMemory = getUsedMemory();
+ long start = System.currentTimeMillis();
+ MyDirectoryWalker walker = new MyDirectoryWalker( basedir, EXCLUDES );
+ walker.scan();
+ System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ showFreeMemory( startMemory );
+ System.out.println( "Files: " + walker.getCount() );
+ }
+
+// private static void scanUsingAntScanner( File basedir )
+// throws InterruptedException
+// {
+// long startMemory = getUsedMemory();
+// long start = System.currentTimeMillis();
+//
+// DirectoryScanner scanner = new DirectoryScanner();
+// scanner.setBasedir( basedir );
+// scanner.setIncludes( new String[]{"**/*"} );
+// scanner.setExcludes( EXCLUDES.toArray( new String[EXCLUDES.size()] ) );
+// scanner.scan();
+// System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+// showFreeMemory( startMemory );
+// System.out.println( "Files: " + scanner.getIncludedFiles().length );
+// }
+
+ private static void scanUsingUtilsScanner( File basedir )
+ throws InterruptedException
+ {
+ long startMemory = getUsedMemory();
+ long start = System.currentTimeMillis();
+
+ org.codehaus.plexus.util.DirectoryScanner scanner = new org.codehaus.plexus.util.DirectoryScanner();
+ scanner.setBasedir( basedir );
+ scanner.setIncludes( new String[]{"**/*"} );
+ scanner.setExcludes( EXCLUDES.toArray( new String[EXCLUDES.size()] ) );
+ scanner.scan();
+ System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ showFreeMemory( startMemory );
+ System.out.println( "Files: " + scanner.getIncludedFiles().length );
+ }
+
+ private static void scanUsingUtilsWalker( File basedir )
+ throws InterruptedException
+ {
+ long startMemory = getUsedMemory();
+ long start = System.currentTimeMillis();
+ org.codehaus.plexus.util.DirectoryWalker walker = new org.codehaus.plexus.util.DirectoryWalker();
+ walker.setBaseDir( basedir );
+// walker.setIncludes( Collections.singletonList( "**/*" ) );
+ walker.setExcludes( EXCLUDES );
+ PlexusUtilsDirectoryWalkListener walkListener = new PlexusUtilsDirectoryWalkListener();
+ walker.addDirectoryWalkListener( walkListener );
+ walker.scan();
+ System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ showFreeMemory( startMemory );
+ System.out.println( "Files: " + walkListener.getCount() );
+ }
+
+ private static void scanUsingNewWalker( File basedir )
+ throws InterruptedException
+ {
+ long startMemory = getUsedMemory();
+ long start = System.currentTimeMillis();
+ DirectoryWalker walker = new DirectoryWalker();
+ walker.setBaseDir( basedir );
+// walker.setIncludes( Collections.singletonList( "**/*" ) );
+ walker.setExcludes( EXCLUDES );
+ MyDirectoryWalkListener walkListener = new MyDirectoryWalkListener();
+ walker.addDirectoryWalkListener( walkListener );
+ walker.scan();
+ System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ showFreeMemory( startMemory );
+ System.out.println( "Files: " + walkListener.getCount() );
+ }
+
+ private static void scanUsingRepositoryScanner( File basedir )
+ throws RepositoryScannerException, InterruptedException
+ {
+ long startMemory = getUsedMemory();
+ long start = System.currentTimeMillis();
+ ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration();
+ config.setLocation( basedir.getAbsolutePath() );
+
+ RepositoryScanner scanner = new DefaultRepositoryScanner();
+ RepositoryScanStatistics stats = scanner.scan( config, Collections.<KnownRepositoryContentConsumer>emptyList(),
+ Collections.<InvalidRepositoryContentConsumer>emptyList(),
+ EXCLUDES, RepositoryScanner.FRESH_SCAN );
+
+ System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ showFreeMemory( startMemory );
+ System.out.println( stats.toDump( config ) );
+ }
+
+ private static long getUsedMemory()
+ throws InterruptedException
+ {
+ gc();
+ return RUNTIME.totalMemory() - RUNTIME.freeMemory();
+ }
+
+ private static void showFreeMemory( long startMemory )
+ throws InterruptedException
+ {
+ System.out.println( "used memory ~" + ( RUNTIME.totalMemory() - RUNTIME.freeMemory() - startMemory ) );
+ long endMemory = getUsedMemory();
+ System.out.println( "retained memory ~" + ( endMemory - startMemory ) );
+ }
+
+ private static void gc()
+ throws InterruptedException
+ {
+ System.gc();
+ Thread.sleep( 3000 );
+ }
+
+ private static final class MyDirectoryWalker
+ extends org.apache.commons.io.DirectoryWalker
+ {
+ private final File basedir;
+
+ private int count = 0;
+
+ public MyDirectoryWalker( File basedir, List<String> excludes )
+ {
+ super( new SelectorFileFilter( convertToPatterns( excludes ) ), -1 );
+
+ this.basedir = basedir;
+ }
+
+ private static List<TokenizedPattern> convertToPatterns( List<String> excludes )
+ {
+ List<TokenizedPattern> patterns = new ArrayList<TokenizedPattern>( excludes.size() );
+
+ for ( String exclude : excludes )
+ {
+ patterns.add( new TokenizedPattern( exclude ) );
+ }
+
+ return patterns;
+ }
+
+ public void scan()
+ throws IOException
+ {
+ super.walk( basedir, null );
+ }
+
+ @Override
+ protected void handleFile( File file, int depth, Collection results )
+ throws IOException
+ {
+ count++;
+ }
+
+ public int getCount()
+ {
+ return count;
+ }
+
+ private static final class SelectorFileFilter
+ implements FileFilter
+ {
+ private List<TokenizedPattern> excludes;
+
+ public SelectorFileFilter( List<TokenizedPattern> excludes )
+ {
+ this.excludes = excludes;
+ }
+
+ public boolean accept( File pathname )
+ {
+ for ( TokenizedPattern exclude : excludes )
+ {
+ if ( exclude.matchPath( pathname.getPath(), true ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ }
+
+ @SuppressWarnings( {"UnusedDeclaration"} )
+ private static abstract class AbstractDirectoryWalkListener
+ {
+ private int count = 0;
+
+ public void directoryWalkStarting( File basedir )
+ {
+ }
+
+ public void directoryWalkStep( int percentage, File file )
+ {
+ count++;
+ }
+
+ public void directoryWalkFinished()
+ {
+ }
+
+ public void debug( String message )
+ {
+ }
+
+ public int getCount()
+ {
+ return count;
+ }
+ }
+
+ private static class PlexusUtilsDirectoryWalkListener
+ extends AbstractDirectoryWalkListener
+ implements org.codehaus.plexus.util.DirectoryWalkListener
+ {
+
+ }
+
+ private static class MyDirectoryWalkListener
+ extends AbstractDirectoryWalkListener
+ implements DirectoryWalkListener
+ {
+
+ }
+
+}
Propchange: archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalkListener.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalkListener.java?rev=917976&view=auto
==============================================================================
--- archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalkListener.java (added)
+++ archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalkListener.java Tue Mar 2 11:42:14 2010
@@ -0,0 +1,51 @@
+package org.apache.archiva;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+/**
+ * DirectoryWalkListener
+ * @version $Id: DirectoryWalkListener.java 5958 2007-02-28 10:29:55Z olamy $
+ */
+public interface DirectoryWalkListener
+{
+ /**
+ * The directory walking has begun.
+ *
+ * @param basedir the basedir that walk started in.
+ */
+ void directoryWalkStarting( File basedir );
+
+ /**
+ * The included entry that was encountered.
+ *
+ * @param percentage rough percentage of the walk completed. (inaccurate)
+ * @param file the file that was included.
+ */
+ void directoryWalkStep( int percentage, File file );
+
+ /**
+ * The directory walking has finished.
+ */
+ void directoryWalkFinished();
+
+ void debug( String message );
+}
\ No newline at end of file
Propchange: archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalkListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalker.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalker.java?rev=917976&view=auto
==============================================================================
--- archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalker.java (added)
+++ archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalker.java Tue Mar 2 11:42:14 2010
@@ -0,0 +1,352 @@
+package org.apache.archiva;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * DirectoryWalker.
+ *
+ * @version $Id: DirectoryWalker.java 5958 2007-02-28 10:29:55Z olamy $
+ */
+public class DirectoryWalker
+{
+ private File baseDir;
+
+ private int baseDirOffset;
+
+ private List<TokenizedPattern> excludes;
+
+ private List<TokenizedPattern> includes;
+
+ private boolean isCaseSensitive = true;
+
+ private List<DirectoryWalkListener> listeners;
+
+ private boolean debugEnabled = false;
+
+ public static final String[] DEFAULTEXCLUDES = {
+ // Miscellaneous typical temporary files
+ "**/*~", "**/#*#", "**/.#*", "**/%*%", "**/._*",
+
+ // CVS
+ "**/CVS", "**/CVS/**", "**/.cvsignore",
+
+ // SCCS
+ "**/SCCS", "**/SCCS/**",
+
+ // Visual SourceSafe
+ "**/vssver.scc",
+
+ // Subversion
+ "**/.svn", "**/.svn/**",
+
+ // Arch
+ "**/.arch-ids", "**/.arch-ids/**",
+
+ //Bazaar
+ "**/.bzr", "**/.bzr/**",
+
+ //SurroundSCM
+ "**/.MySCMServerInfo",
+
+ // Mac
+ "**/.DS_Store"};
+
+ public DirectoryWalker()
+ {
+ this.includes = new ArrayList<TokenizedPattern>();
+ this.excludes = new ArrayList<TokenizedPattern>();
+ this.listeners = new ArrayList<DirectoryWalkListener>();
+ }
+
+ public void addDirectoryWalkListener( DirectoryWalkListener listener )
+ {
+ this.listeners.add( listener );
+ }
+
+ public void addExclude( String exclude )
+ {
+ this.excludes.add( fixPattern( exclude ) );
+ }
+
+ public void addInclude( String include )
+ {
+ this.includes.add( fixPattern( include ) );
+ }
+
+ /**
+ * Add's to the Exclude List the default list of SCM excludes.
+ */
+ public void addSCMExcludes()
+ {
+ String scmexcludes[] = DEFAULTEXCLUDES;
+ for ( String scmexclude : scmexcludes )
+ {
+ addExclude( scmexclude );
+ }
+ }
+
+ private void fireStep( File file )
+ {
+ for ( DirectoryWalkListener listener : this.listeners )
+ {
+ listener.directoryWalkStep( 0, file );
+ }
+ }
+
+ private void fireWalkFinished()
+ {
+ for ( DirectoryWalkListener listener : this.listeners )
+ {
+ listener.directoryWalkFinished();
+ }
+ }
+
+ private void fireWalkStarting()
+ {
+ for ( DirectoryWalkListener listener : this.listeners )
+ {
+ listener.directoryWalkStarting( this.baseDir );
+ }
+ }
+
+ private void fireDebugMessage( String message )
+ {
+ for ( DirectoryWalkListener listener : this.listeners )
+ {
+ listener.debug( message );
+ }
+ }
+
+ private TokenizedPattern fixPattern( String pattern )
+ {
+ String cleanPattern = pattern;
+
+ if ( File.separatorChar != '/' )
+ {
+ cleanPattern = cleanPattern.replace( '/', File.separatorChar );
+ }
+
+ if ( File.separatorChar != '\\' )
+ {
+ cleanPattern = cleanPattern.replace( '\\', File.separatorChar );
+ }
+
+ return new TokenizedPattern( cleanPattern );
+ }
+
+ public void setDebugMode( boolean debugEnabled )
+ {
+ this.debugEnabled = debugEnabled;
+ }
+
+ /**
+ * @return Returns the baseDir.
+ */
+ public File getBaseDir()
+ {
+ return baseDir;
+ }
+
+ /**
+ * @return Returns the excludes.
+ */
+ public List getExcludes()
+ {
+ return excludes;
+ }
+
+ /**
+ * @return Returns the includes.
+ */
+ public List getIncludes()
+ {
+ return includes;
+ }
+
+ private boolean isExcluded( String name )
+ {
+ return isMatch( this.excludes, name );
+ }
+
+ private boolean isIncluded( String name )
+ {
+ return isMatch( this.includes, name );
+ }
+
+ private boolean isMatch( List<TokenizedPattern> patterns, String name )
+ {
+ for ( TokenizedPattern pattern : patterns )
+ {
+ if ( pattern.matchPath( name, isCaseSensitive ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private String relativeToBaseDir( File file )
+ {
+ return file.getAbsolutePath().substring( baseDirOffset + 1 );
+ }
+
+ /**
+ * Removes a DirectoryWalkListener.
+ *
+ * @param listener the listener to remove.
+ */
+ public void removeDirectoryWalkListener( DirectoryWalkListener listener )
+ {
+ this.listeners.remove( listener );
+ }
+
+ /**
+ * Performs a Scan against the provided {@link #setBaseDir(java.io.File)}
+ */
+ public void scan()
+ {
+ if ( baseDir == null )
+ {
+ throw new IllegalStateException( "Scan Failure. BaseDir not specified." );
+ }
+
+ if ( !baseDir.exists() )
+ {
+ throw new IllegalStateException( "Scan Failure. BaseDir does not exist." );
+ }
+
+ if ( !baseDir.isDirectory() )
+ {
+ throw new IllegalStateException( "Scan Failure. BaseDir is not a directory." );
+ }
+
+ if ( this.includes.isEmpty() )
+ {
+ // default to include all.
+ addInclude( "**" );
+ }
+
+ if ( debugEnabled )
+ {
+ Iterator it;
+ StringBuffer dbg = new StringBuffer();
+ dbg.append( "DirectoryWalker Scan" );
+ dbg.append( "\n Base Dir: " ).append( this.baseDir.getAbsolutePath() );
+ dbg.append( "\n Includes: " );
+ it = this.includes.iterator();
+ while ( it.hasNext() )
+ {
+ String include = (String) it.next();
+ dbg.append( "\n - \"" ).append( include ).append( "\"" );
+ }
+ dbg.append( "\n Excludes: " );
+ it = this.excludes.iterator();
+ while ( it.hasNext() )
+ {
+ String exclude = (String) it.next();
+ dbg.append( "\n - \"" ).append( exclude ).append( "\"" );
+ }
+ fireDebugMessage( dbg.toString() );
+ }
+
+ fireWalkStarting();
+ scanDir( this.baseDir );
+ fireWalkFinished();
+ }
+
+ private void scanDir( File dir )
+ {
+ File files[] = dir.listFiles();
+
+ if ( files == null )
+ {
+ return;
+ }
+
+ for ( File file : files )
+ {
+ String name = relativeToBaseDir( file );
+
+ if ( isExcluded( name ) )
+ {
+ fireDebugMessage( name + " is excluded." );
+ continue;
+ }
+
+ if ( file.isDirectory() )
+ {
+ scanDir( file );
+ }
+ else
+ {
+ if ( isIncluded( name ) )
+ {
+ fireStep( file );
+ }
+ }
+ }
+ }
+
+ /**
+ * @param baseDir The baseDir to set.
+ */
+ public void setBaseDir( File baseDir )
+ {
+ this.baseDir = baseDir;
+ this.baseDirOffset = baseDir.getAbsolutePath().length();
+ }
+
+ /**
+ * @param entries The excludes to set.
+ */
+ public void setExcludes( List<String> entries )
+ {
+ this.excludes.clear();
+ if ( entries != null )
+ {
+ for ( String entry : entries )
+ {
+ this.excludes.add( fixPattern( entry ) );
+ }
+ }
+ }
+
+ /**
+ * @param entries The includes to set.
+ */
+ public void setIncludes( List<String> entries )
+ {
+ this.includes.clear();
+ if ( entries != null )
+ {
+ for ( String entry : entries )
+ {
+ this.includes.add( fixPattern( entry ) );
+ }
+ }
+ }
+
+}
\ No newline at end of file
Propchange: archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/DirectoryWalker.java
------------------------------------------------------------------------------
svn:eol-style = native