Index: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitSession.java
===================================================================
--- jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitSession.java	(revision 718913)
+++ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitSession.java	(working copy)
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.api;
 
+import org.apache.jackrabbit.api.data.DataStoreGarbageCollector;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 
@@ -53,4 +54,13 @@
      * @see UserManager
      */
     UserManager getUserManager() throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException;
+    
+    /**
+     * Create a data store garbage collector for this repository.
+     *
+     * @return the data store garbage collector if the data store is enabled, null otherwise
+     * @throws RepositoryException
+     */
+    DataStoreGarbageCollector createDataStoreGarbageCollector() throws RepositoryException;
+    
 }
\ No newline at end of file
Index: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/data/MarkEventListener.java
===================================================================
--- jackrabbit-api/src/main/java/org/apache/jackrabbit/api/data/MarkEventListener.java	(revision 0)
+++ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/data/MarkEventListener.java	(revision 0)
@@ -0,0 +1,24 @@
+package org.apache.jackrabbit.api.data;
+
+import java.util.EventListener;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+public interface MarkEventListener extends EventListener {
+
+    /**
+     * This method is called before a node is scanned.
+     */
+    void beforeScanning(Node n) throws RepositoryException;
+
+    /**
+     * This method is called after a node is scanned.
+     */
+    void afterScanning(Node n) throws RepositoryException;
+
+    /**
+     * This method is called when the garbage collection scan is finished.
+     */
+    void done();
+}
\ No newline at end of file

Property changes on: C:\data\jackrabbit\jackrabbit-api\src\main\java\org\apache\jackrabbit\api\data\MarkEventListener.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision Rev URL
Name: svn:eol-style
   + native

Index: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/data/DataStoreGarbageCollector.java
===================================================================
--- jackrabbit-api/src/main/java/org/apache/jackrabbit/api/data/DataStoreGarbageCollector.java	(revision 0)
+++ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/data/DataStoreGarbageCollector.java	(revision 0)
@@ -0,0 +1,87 @@
+package org.apache.jackrabbit.api.data;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Garbage collector for DataStore. This implementation is iterates through all
+ * nodes and reads the binary properties. To detect nodes that are moved while
+ * the scan runs, event listeners are started. Like the well known garbage
+ * collection in Java, the items that are still in use are marked. Currently
+ * this achieved by updating the modified date of the entries. Newly added
+ * entries are detected because the modified date is changed when they are
+ * added.
+ * <p>
+ * Example code to run the data store garbage collection:
+ * <pre>
+ * DataStoreGarbageCollector gc = ((JackrabbitSession)session).createDataStoreGarbageCollector();
+ * gc.scan();
+ * gc.stopScan();
+ * gc.deleteUnused();
+ * </pre>
+ */
+public interface DataStoreGarbageCollector {
+
+    /**
+     * Set the delay between scanning items.
+     * The main scan loop sleeps this many milliseconds after
+     * scanning a node. The default is 0, meaning the scan should run at full speed.
+     *
+     * @param sleepBetweenNodes the number of milliseconds to sleep
+     */
+    void setSleepBetweenNodes(int millis);
+    
+    /**
+     * Set the event listener. If set, the event listener will be called
+     * for each item that is scanned. This mechanism can be used
+     * to display the progress.
+     *
+     * @param callback if set, this is called while scanning
+     */
+    void setMarkEventListener(MarkEventListener callback);
+    
+    
+    /**
+     * Enable or disable using the IterablePersistenceManager interface
+     * to scan the items. This is important for clients that need
+     * the complete Node implementation in the ScanEventListener
+     * callback.
+     *
+     * @param allow true if using the IterablePersistenceManager interface is allowed
+     */
+    void setPersistenceManagerScan(boolean allow);
+    
+    /**
+     * Check if using the IterablePersistenceManager interface is allowed.
+     *
+     * @return true if using IterablePersistenceManager is possible.
+     */
+    boolean getPersistenceManagerScan();
+    
+    /**
+     * Scan the repository. The garbage collector will iterate over all nodes in the repository
+     * and update the last modified date. If all persistence managers implement the
+     * IterablePersistenceManager interface, this mechanism will be used; if not, the garbage
+     * collector will scan the repository using the JCR API starting from the root node.
+     *
+     * @throws RepositoryException
+     */
+    void scan() throws RepositoryException;
+    
+    /**
+     * Stop scanning. This method must be called after the scanning, and before 
+     * deleting all unused objects. It should be called even if {@link deleteUnused}
+     * is not called, to reclaim resources.
+     * 
+     * @throws RepositoryException
+     */
+    void stopScan() throws RepositoryException;
+    
+    /**
+     * Delete all unused data store objects.
+     * 
+     * @return the number of deleted objects
+     * @throws RepositoryException 
+     */
+    int deleteUnused() throws RepositoryException;
+
+}

Property changes on: C:\data\jackrabbit\jackrabbit-api\src\main\java\org\apache\jackrabbit\api\data\DataStoreGarbageCollector.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision Rev URL
Name: svn:eol-style
   + native

