diff -ruNbB --exclude '*.tmp' --exclude src_xindice.txt --exclude out.xml --exclude '*.xln' --exclude '*.jcp' --exclude '*.log' --exclude err --exclude CVS --exclude docs --exclude map.out /cygdrive/d/xindice/1.0/xml-xindice/java/src/org/apache/xindice/core/Collection.java xindice-stage/java/src/org/apache/xindice/core/Collection.java
--- /cygdrive/d/xindice/1.0/xml-xindice/java/src/org/apache/xindice/core/Collection.java	2001-12-06 12:00:11.000000000 -0800
+++ xindice-stage/java/src/org/apache/xindice/core/Collection.java	2002-06-18 10:27:17.000000000 -0700
@@ -214,6 +214,9 @@
       }
       
       super.setConfig(config);
+
+      // observer      
+      DBObserver.getInstance().setCollectionConfig(this, config);
    }
 
    public final String getName() {
@@ -520,6 +523,8 @@
       if ( this == getDatabase() )
          throw new DBException(FaultCodes.DBE_CANNOT_DROP, "You Cannot Drop The Database");
 
+      DBObserver.getInstance().dropCollection(this);
+      
       // Drop Child Collections
       String[] cols = listCollections();
       for ( int i = 0; i < cols.length; i++ )
@@ -635,6 +640,9 @@
          else
             documentCache.putDocument(this, key, document);
       }
+
+      DBObserver.getInstance().putDocument(this, key, document, 
+         oldDoc == null);
    }
 
    /**
@@ -690,6 +698,8 @@
 
       if ( !filer.deleteRecord(objKey) )
          throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND, "Document Does Not Exist");
+
+      DBObserver.getInstance().dropDocument(this, objKey);
    }
 
    /**
@@ -727,6 +737,8 @@
             doc = parseDocument(key, value.toString());
          
          flushSymbolTable();
+
+         DBObserver.getInstance().loadDocument(this, record, doc);
       }
       return doc;
    }
diff -ruNbB --exclude '*.tmp' --exclude src_xindice.txt --exclude out.xml --exclude '*.xln' --exclude '*.jcp' --exclude '*.log' --exclude err --exclude CVS --exclude docs --exclude map.out /cygdrive/d/xindice/1.0/xml-xindice/java/src/org/apache/xindice/core/DBObserver.java xindice-stage/java/src/org/apache/xindice/core/DBObserver.java
--- /cygdrive/d/xindice/1.0/xml-xindice/java/src/org/apache/xindice/core/DBObserver.java	1969-12-31 16:00:00.000000000 -0800
+++ xindice-stage/java/src/org/apache/xindice/core/DBObserver.java	2002-06-06 17:51:10.000000000 -0700
@@ -0,0 +1,109 @@
+package org.apache.xindice.core;
+
+import java.io.File;
+import java.io.File;
+import java.util.Map;
+import org.w3c.dom.Document;
+
+import org.apache.xindice.core.DBException;
+import org.apache.xindice.core.Collection;
+import org.apache.xindice.core.Database;
+import org.apache.xindice.core.data.Key;
+import org.apache.xindice.core.data.Record;
+import org.apache.xindice.util.Configuration;
+
+/**
+ * Observer for Xindice DB activities
+ */
+public abstract class DBObserver
+{
+    private static final DBObserver NOOP = new DBObserver()
+    {
+        public void setDatabaseConfig( 
+        Database db, Map collections, Configuration cfg ) {}
+
+        public void setCollectionConfig( 
+        Collection col, Configuration cfg ) {}
+
+        public void flushDatabaseConfig( 
+        Database db, Configuration cfg ) {}
+    
+        public void dropCollection( Collection col ) 
+        throws DBException {}
+
+        public void putDocument( 
+        Collection col, Key key, Document document, boolean create ) 
+        throws DBException {}
+
+        public void loadDocument( 
+            Collection col, Record record, Document document ) 
+        throws DBException {}
+        
+        public void dropDocument( Collection col, Key key ) 
+        throws DBException {}
+    };
+
+    private static DBObserver instance = NOOP;
+
+    /**
+     * Sets the default observer instance
+     */ 
+    public static void setInstance( DBObserver obs )
+    { 
+        instance = (null == obs) ? NOOP : obs; 
+    }
+
+    /**
+     * Returns the observer instance, must be non-null
+     */    
+    public static DBObserver getInstance()
+    { 
+        return instance; 
+    }
+    
+    /**
+     * Called after Database.setConfig()
+     */    
+    public abstract void setDatabaseConfig( 
+        Database db, Map collections, Configuration cfg );
+
+    /**
+     * Called after Collection.setConfig()
+     */    
+    public abstract void setCollectionConfig( 
+        Collection col, Configuration cfg );
+
+    /**
+     * Called after Database.flushConfig()
+     */
+    public abstract void flushDatabaseConfig( 
+        Database db, Configuration cfg );
+    
+    /**
+     * Called before Collection.drop()
+     */
+    public abstract void dropCollection( Collection col ) 
+    throws DBException;
+
+    /**
+     * Called after Collection.putDocument()
+     */    
+    public abstract void putDocument( 
+        Collection col, Key key, Document document, boolean create ) 
+    throws DBException;
+
+    /**
+     * Called after Collection.getDocument()
+     */    
+    public abstract void loadDocument( 
+        Collection col, Record record, Document document ) 
+    throws DBException;
+
+    /**
+     * Called before Collection.remove(key)
+     */
+    public abstract void dropDocument( Collection col, Key key ) 
+    throws DBException;
+    
+}
+
diff -ruNbB --exclude '*.tmp' --exclude src_xindice.txt --exclude out.xml --exclude '*.xln' --exclude '*.jcp' --exclude '*.log' --exclude err --exclude CVS --exclude docs --exclude map.out /cygdrive/d/xindice/1.0/xml-xindice/java/src/org/apache/xindice/core/Database.java xindice-stage/java/src/org/apache/xindice/core/Database.java
--- /cygdrive/d/xindice/1.0/xml-xindice/java/src/org/apache/xindice/core/Database.java	2002-02-25 22:10:09.000000000 -0800
+++ xindice-stage/java/src/org/apache/xindice/core/Database.java	2002-06-13 14:22:36.000000000 -0700
@@ -200,6 +200,9 @@
 
       // Register the Database with the VM
       databases.put(getName(), this);
+
+      // observer 
+      DBObserver.getInstance().setDatabaseConfig(this, collections, config);
    }
 
    public SystemCollection getSystemCollection() {
@@ -222,6 +225,8 @@
       catch ( Exception e ) {
          org.apache.xindice.Debug.println(this, "Error Writing Configuration '"+name+"'");
       }
+      // observer      
+      DBObserver.getInstance().flushDatabaseConfig(this, config);
    }
   
    public boolean close() throws DBException {
diff -ruNbB --exclude '*.tmp' --exclude src_xindice.txt --exclude out.xml --exclude '*.xln' --exclude '*.jcp' --exclude '*.log' --exclude err --exclude CVS --exclude docs --exclude map.out /cygdrive/d/xindice/1.0/xml-xindice/java/src/org/apache/xindice/server/services/XindiceService.java xindice-stage/java/src/org/apache/xindice/server/services/XindiceService.java
--- /cygdrive/d/xindice/1.0/xml-xindice/java/src/org/apache/xindice/server/services/XindiceService.java	2001-12-06 10:33:56.000000000 -0800
+++ xindice-stage/java/src/org/apache/xindice/server/services/XindiceService.java	2002-06-14 16:33:20.000000000 -0700
@@ -65,6 +65,7 @@
 import org.apache.xindice.util.SimpleConfigurable;
 import org.apache.xindice.util.XindiceException;
 import org.apache.xindice.core.Database;
+import org.apache.xindice.core.DBObserver;
 
 /**
  * XindiceService controls the Xindice server instance.
@@ -74,7 +75,9 @@
 public class XindiceService extends SimpleConfigurable
       implements Service, KernelAccess {
    private static final String ROOT_COLLECTION = "root-collection";
+   private static final String OBSERVER = "db-observer";
    private static final String NAME = "name";
+   private static final String CLASS = "class";
 
    protected Kernel kernel;
    protected Configuration config;
@@ -90,6 +93,18 @@
       try {
          this.config = config.getChild(ROOT_COLLECTION);
          serviceName = this.config.getAttribute(NAME);
+
+         Configuration obsConfig = config.getChild(OBSERVER);
+         if( null != obsConfig )
+         {
+            String obsClassName = obsConfig.getAttribute(CLASS);
+            
+            Class obsClass = Class.forName(obsClassName);
+            DBObserver obs = (DBObserver)obsClass.newInstance();
+            DBObserver.setInstance(obs);
+
+            System.out.println("Register DB Observer: '" + obsClassName + "'");
+         }
       } catch (Exception e) {
          org.apache.xindice.Debug.println(this, e);
       }
