Merge branch 'master' of ssh://git.eclipse.org/gitroot/virgo/org.eclipse.virgo.artifact-repository

Conflicts:
	org.eclipse.virgo.repository/.classpath
diff --git a/build.versions b/build.versions
index 3b6add2..2927c06 100644
--- a/build.versions
+++ b/build.versions
@@ -3,8 +3,8 @@
 org.slf4j.api=1.6.4.v20120130-2120
 org.apache.commons.httpclient=3.1.0
 org.eclipse.osgi=3.8.0.v20120508-2119
-org.eclipse.virgo.medic=3.6.0.D-20120829083907
-org.eclipse.virgo.util=3.6.0.D-20120829083441
+org.eclipse.virgo.medic=3.6.0.D-20120917213450
+org.eclipse.virgo.util=3.6.0.D-20120917212716
 org.junit=4.7.0
 org.easymock=2.3.0
-org.eclipse.virgo.test=3.6.0.D-20120829083717
+org.eclipse.virgo.test=3.6.0.D-20120917213231
diff --git a/org.eclipse.virgo.repository/.classpath b/org.eclipse.virgo.repository/.classpath
index fc2f878..057578c 100644
--- a/org.eclipse.virgo.repository/.classpath
+++ b/org.eclipse.virgo.repository/.classpath
@@ -21,22 +21,22 @@
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-2.3.0.jar" sourcepath="/IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-sources-2.3.0.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/3.6.0.D-20120829083441/org.eclipse.virgo.util.io-3.6.0.D-20120829083441.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/3.6.0.D-20120829083441/org.eclipse.virgo.util.io-sources-3.6.0.D-20120829083441.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.6.0.D-20120829083441/org.eclipse.virgo.util.common-3.6.0.D-20120829083441.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.6.0.D-20120829083441/org.eclipse.virgo.util.common-sources-3.6.0.D-20120829083441.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.6.0.D-20120829083441/org.eclipse.virgo.util.osgi-3.6.0.D-20120829083441.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.6.0.D-20120829083441/org.eclipse.virgo.util.osgi-sources-3.6.0.D-20120829083441.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.codec/1.3.0/com.springsource.org.apache.commons.codec-1.3.0.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.osgi/3.8.0.v20120508-2119/org.eclipse.osgi-3.8.0.v20120508-2119.jar" sourcepath="/IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.1.R37x_v20110808-1106/org.eclipse.osgi-sources-3.7.1.R37x_v20110808-1106.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.math/3.6.0.D-20120829083441/org.eclipse.virgo.util.math-3.6.0.D-20120829083441.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.math/3.6.0.D-20120829083441/org.eclipse.virgo.util.math-sources-3.6.0.D-20120829083441.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.slf4j.api/1.6.4.v20120130-2120/org.slf4j.api-1.6.4.v20120130-2120.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic/3.6.0.D-20120829083907/org.eclipse.virgo.medic-3.6.0.D-20120829083907.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic/3.6.0.D-20120829083907/org.eclipse.virgo.medic-sources-3.6.0.D-20120829083907.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.slf4j/com.springsource.slf4j.nop/1.6.1/com.springsource.slf4j.nop-1.6.1.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic.test/3.6.0.D-20120829083907/org.eclipse.virgo.medic.test-3.6.0.D-20120829083907.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic.test/3.6.0.D-20120829083907/org.eclipse.virgo.medic.test-sources-3.6.0.D-20120829083907.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.aspectj/com.springsource.org.aspectj.runtime/1.6.12.RELEASE/com.springsource.org.aspectj.runtime-1.6.12.RELEASE.jar" sourcepath="/IVY_CACHE/org.aspectj/com.springsource.org.aspectj.runtime/1.6.6.BUILD-20090909/com.springsource.org.aspectj.runtime-sources-1.6.6.BUILD-20090909.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.test/org.eclipse.virgo.test.stubs/3.6.0.D-20120829083717/org.eclipse.virgo.test.stubs-3.6.0.D-20120829083717.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.test/org.eclipse.virgo.teststubs.osgi/3.6.0.D-20120711092322/org.eclipse.virgo.teststubs.osgi-3.6.0.D-20120711092322.jar"/>
-	<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi.manifest/3.6.0.D-20120829083441/org.eclipse.virgo.util.osgi.manifest-3.6.0.D-20120829083441.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-2.3.0.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-sources-2.3.0.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/3.6.0.D-20120917212716/org.eclipse.virgo.util.io-3.6.0.D-20120917212716.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/3.6.0.D-20120917212716/org.eclipse.virgo.util.io-sources-3.6.0.D-20120917212716.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.6.0.D-20120917212716/org.eclipse.virgo.util.common-3.6.0.D-20120917212716.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.6.0.D-20120917212716/org.eclipse.virgo.util.common-sources-3.6.0.D-20120917212716.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.6.0.D-20120917212716/org.eclipse.virgo.util.osgi-3.6.0.D-20120917212716.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.6.0.D-20120917212716/org.eclipse.virgo.util.osgi-sources-3.6.0.D-20120917212716.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.codec/1.3.0/com.springsource.org.apache.commons.codec-1.3.0.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.osgi/3.8.0.v20120508-2119/org.eclipse.osgi-3.8.0.v20120508-2119.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.1.R37x_v20110808-1106/org.eclipse.osgi-sources-3.7.1.R37x_v20110808-1106.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.math/3.6.0.D-20120917212716/org.eclipse.virgo.util.math-3.6.0.D-20120917212716.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.math/3.6.0.D-20120917212716/org.eclipse.virgo.util.math-sources-3.6.0.D-20120917212716.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.mirrored/org.slf4j.api/1.6.4.v20120130-2120/org.slf4j.api-1.6.4.v20120130-2120.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic/3.6.0.D-20120917213450/org.eclipse.virgo.medic-3.6.0.D-20120917213450.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic/3.6.0.D-20120917213450/org.eclipse.virgo.medic-sources-3.6.0.D-20120917213450.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.slf4j/com.springsource.slf4j.nop/1.6.1/com.springsource.slf4j.nop-1.6.1.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic.test/3.6.0.D-20120917213450/org.eclipse.virgo.medic.test-3.6.0.D-20120917213450.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic.test/3.6.0.D-20120917213450/org.eclipse.virgo.medic.test-sources-3.6.0.D-20120917213450.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.aspectj/com.springsource.org.aspectj.runtime/1.6.12.RELEASE/com.springsource.org.aspectj.runtime-1.6.12.RELEASE.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.aspectj/com.springsource.org.aspectj.runtime/1.6.6.BUILD-20090909/com.springsource.org.aspectj.runtime-sources-1.6.6.BUILD-20090909.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.test/org.eclipse.virgo.test.stubs/3.6.0.D-20120917213231/org.eclipse.virgo.test.stubs-3.6.0.D-20120917213231.jar" sourcepath="/REPOSITORY_IVY_CACHE/org.eclipse.virgo.test/org.eclipse.virgo.teststubs.osgi/3.6.0.D-20120711092322/org.eclipse.virgo.teststubs.osgi-3.6.0.D-20120711092322.jar"/>
+	<classpathentry kind="var" path="REPOSITORY_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi.manifest/3.6.0.D-20120917212716/org.eclipse.virgo.util.osgi.manifest-3.6.0.D-20120917212716.jar"/>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>
diff --git a/org.eclipse.virgo.repository/src/main/java/org/eclipse/virgo/repository/internal/watched/WatchedStorageRepository.java b/org.eclipse.virgo.repository/src/main/java/org/eclipse/virgo/repository/internal/watched/WatchedStorageRepository.java
index e096c1c..c663f47 100644
--- a/org.eclipse.virgo.repository/src/main/java/org/eclipse/virgo/repository/internal/watched/WatchedStorageRepository.java
+++ b/org.eclipse.virgo.repository/src/main/java/org/eclipse/virgo/repository/internal/watched/WatchedStorageRepository.java
@@ -14,6 +14,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -22,9 +23,6 @@
 
 import javax.management.JMException;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.eclipse.virgo.medic.eventlog.EventLogger;
 import org.eclipse.virgo.repository.ArtifactDescriptorPersister;
 import org.eclipse.virgo.repository.DuplicateArtifactException;
@@ -42,6 +40,8 @@
 import org.eclipse.virgo.util.io.FileSystemChecker;
 import org.eclipse.virgo.util.io.FileSystemEvent;
 import org.eclipse.virgo.util.io.FileSystemListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A {@link Repository} that watches a local directory and automatically publishes and retracts artifacts placed (or
@@ -53,40 +53,41 @@
  * </p>
  * 
  */
-public final class WatchedStorageRepository extends LocalRepository  implements WatchableRepository {
-
+public final class WatchedStorageRepository extends LocalRepository implements WatchableRepository {
+    
     private static final Logger LOGGER = LoggerFactory.getLogger(WatchedStorageRepository.class);
-
+    
     private static final String EXCLUDE_PATTERN = "\\.DS_Store";
-
+    
     private final DirectoryWatcher dirWatcher; // monitors the watched directory
-
+    
     private final ScheduledExecutorService executorService; // controls the watching threads
-
+    
     private final int watchInterval;
-
+    
     private final File watchDirectory;
-
+    
     private final EventLogger eventLogger;
-
+    
     public WatchedStorageRepository(WatchedStorageRepositoryConfiguration configuration, EventLogger eventLogger) throws RepositoryCreationException,
-        IndexFormatException {
+    IndexFormatException {
         this(configuration, new NoOpArtifactDescriptorPersister(), eventLogger);
     }
-
-    public WatchedStorageRepository(WatchedStorageRepositoryConfiguration configuration, ArtifactDescriptorPersister artifactDescriptorPersister, EventLogger eventLogger) throws RepositoryCreationException,
-        IndexFormatException {
+    
+    public WatchedStorageRepository(WatchedStorageRepositoryConfiguration configuration, ArtifactDescriptorPersister artifactDescriptorPersister,
+                                    EventLogger eventLogger) throws RepositoryCreationException, IndexFormatException {
         super(configuration, artifactDescriptorPersister, eventLogger);
-
+        
         this.eventLogger = eventLogger;
-
+        
         this.watchDirectory = configuration.getDirectoryToWatch();
         this.dirWatcher = new DirectoryWatcher(this.watchDirectory);
         this.watchInterval = configuration.getWatchInterval();
-
+        
         // create thread pool for watching the directory, containing one daemon thread.
         this.executorService = Executors.newScheduledThreadPool(1, new ThreadFactory() {
-
+            
+            @Override
             public Thread newThread(Runnable r) {
                 Thread thread = new Thread(r);
                 thread.setDaemon(true);
@@ -94,7 +95,7 @@
             }
         });
     }
-
+    
     /**
      * Start the base repository and periodic checking.
      */
@@ -102,13 +103,13 @@
     public void start() {
         super.start();
         LOGGER.info("Starting to watch directory '{}'; period {}s.", this.watchDirectory, this.watchInterval);
-
+        
         // do initial check
         this.dirWatcher.fsChecker.check();
         // start periodic checking
         this.executorService.scheduleAtFixedRate(this.dirWatcher, this.watchInterval, this.watchInterval, TimeUnit.SECONDS);
     }
-
+    
     /**
      * Stop watching the repository store and stop the base repository.
      */
@@ -118,27 +119,29 @@
         this.executorService.shutdown();
         super.stop();
     }
-
+    
     /**
      * Private {@link Runnable}, an instance of which watches the directory for us
      */
     private final class DirectoryWatcher implements Runnable {
-
+        
         private final FileSystemChecker fsChecker;
-
+        
         private final FileSystemListener listener;
-
+        
         private DirectoryWatcher(final File directory) throws RepositoryCreationException {
             establishDirectory(directory);
-
+            
             this.fsChecker = new FileSystemChecker(directory, EXCLUDE_PATTERN);
-
+            
             this.listener = new FileSystemListener() {
-
+                
+                @Override
                 public void onChange(String path, FileSystemEvent event) {
                     File file = new File(path);
                     try {
-                        LOGGER.debug("Listener for '{}' heard event '{}' on file '{}'.", new Object[] { watchDirectory, event, file });
+                        LOGGER.debug("Listener for '{}' heard event '{}' on file '{}'.", new Object[] { WatchedStorageRepository.this.watchDirectory,
+                            event, file });
                         switch (event) {
                             case CREATED:
                             case INITIAL: {
@@ -160,36 +163,46 @@
                                 break;
                             }
                         }
-
+                        
                         getDepository().persist();
                     } catch (DuplicateArtifactException dae) {
-                        LOGGER.warn("Duplicate artifact in file '{}' detected in watched directory '{}'.", file, watchDirectory);
+                        LOGGER.warn("Duplicate artifact in file '{}' detected in watched directory '{}'.", file,
+                                    WatchedStorageRepository.this.watchDirectory);
                     } catch (IOException e) {
-                        LOGGER.error(String.format("Watched directory '%s' failed during persist. Stopping repository.", watchDirectory), e);
+                        LOGGER.error(String.format("Watched directory '%s' failed during persist. Stopping repository.",
+                                                   WatchedStorageRepository.this.watchDirectory), e);
                         stop();
-                        eventLogger.log(RepositoryLogEvents.REPOSITORY_NOT_AVAILABLE, e, getName());
+                        WatchedStorageRepository.this.eventLogger.log(RepositoryLogEvents.REPOSITORY_NOT_AVAILABLE, e, getName());
                     }
                 }
+                
+                @Override
+                public void onInitialEvent(List<String> paths) {
+                    // no-op
+                    // not available for watched repository
+                    // only applicable for the pickup directory on a server's startup
+                }
             };
             this.fsChecker.addListener(this.listener);
         }
-
+        
+        @Override
         public void run() {
             try {
                 this.fsChecker.check();
             } catch (Exception e) {
                 LOGGER.error("File system watcher for repository '{}' failed. Repository stopped.", getName());
                 stop();
-                eventLogger.log(RepositoryLogEvents.REPOSITORY_NOT_AVAILABLE, e, getName());
+                WatchedStorageRepository.this.eventLogger.log(RepositoryLogEvents.REPOSITORY_NOT_AVAILABLE, e, getName());
             }
         }
-
+        
         private final void establishDirectory(File dir) throws RepositoryCreationException {
             if (dir.exists()) {
                 if (!dir.isDirectory()) {
                     if (!dir.delete()) {
                         LOGGER.error("Directory '{}' for watched repository '{}' is already a file and cannot be deleted. Repository unavailable.",
-                            dir.getName(), getName());
+                                     dir.getName(), getName());
                         throw new RepositoryCreationException("Failed to delete index file for repository '" + getName() + "'");
                     } else {
                         LOGGER.debug("File '{}' deleted to create directory for watched repository '{}'.", dir, getName());
@@ -206,12 +219,14 @@
         
         /**
          * Run a check against the directory, accumulating new files completely.
+         * 
          * @throws Exception anything that might escape from fs.check()
          */
         public void forceNewCheck() throws Exception {
             try {
                 this.fsChecker.check();
-                // The second check() is to force indexing of new files based on DirectoryWatcher.onChange() implementation.
+                // The second check() is to force indexing of new files based on DirectoryWatcher.onChange()
+                // implementation.
                 this.fsChecker.check();
             } catch (Exception e) {
                 LOGGER.warn("Directory check for repository '{}' failed.", getName());
@@ -219,7 +234,7 @@
             }
         }
     }
-
+    
     /**
      * {@inheritDoc}
      */
@@ -229,17 +244,20 @@
     }
     
     /**
-     * Performs a directory check upon the watched directory; equivalent to waiting for the directory file system checker to run, but
-     * is synchronous.
+     * Performs a directory check upon the watched directory; equivalent to waiting for the directory file system
+     * checker to run, but is synchronous.
+     * 
      * @throws Exception from directory watcher
      */
+    @Override
     public void forceCheck() throws Exception {
         this.dirWatcher.forceNewCheck();
     }
-
+    
+    @Override
     public Set<String> getArtifactLocations(String filename) {
         Set<String> locations = new HashSet<String>(1);
-        locations.add(new File(this.watchDirectory,filename).getAbsolutePath());
+        locations.add(new File(this.watchDirectory, filename).getAbsolutePath());
         return locations;
     }
 }
diff --git a/virgo-build b/virgo-build
index f7d22aa..4b68d5a 160000
--- a/virgo-build
+++ b/virgo-build
@@ -1 +1 @@
-Subproject commit f7d22aa0e5a022770c290b892e98941e4a51b9d8
+Subproject commit 4b68d5a489f561dfada9780039dc4b96bfcc8485