From 6e6c3ff6bfd2893df3215160dfa2029b01f2906e Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Fri, 26 Sep 2008 18:31:47 +0000 Subject: Resync listener is now a trigger in order to capture more information. --- .../carbonado/capability/ResyncCapability.java | 36 +++++++++------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/capability') diff --git a/src/main/java/com/amazon/carbonado/capability/ResyncCapability.java b/src/main/java/com/amazon/carbonado/capability/ResyncCapability.java index 337afb0..33efca7 100644 --- a/src/main/java/com/amazon/carbonado/capability/ResyncCapability.java +++ b/src/main/java/com/amazon/carbonado/capability/ResyncCapability.java @@ -18,9 +18,11 @@ package com.amazon.carbonado.capability; +import com.amazon.carbonado.PersistException; import com.amazon.carbonado.Repository; import com.amazon.carbonado.RepositoryException; import com.amazon.carbonado.Storable; +import com.amazon.carbonado.Trigger; /** * Capability of replicating repositories for re-synchronizing to the master @@ -70,8 +72,8 @@ public interface ResyncCapability extends Capability { Repository getMasterRepository(); /** - * Defines callbacks which are invoked as storables get re-sync'd. The - * callback is invoked in the scope of the resync transaction. If any + * Trigger which is invoked as storables get re-sync'd. Callbacks are + * invoked in the scope of the resync transaction. If any unchecked * exception is thrown, the immediate changes are rolled back and the * entire repository resync operation is aborted. * @@ -81,28 +83,18 @@ public interface ResyncCapability extends Capability { * queue. A separate thread can then perform the repairs outside the resync * transaction. */ - public static interface Listener { + public static class Listener extends Trigger { /** - * Called when a storable was inserted as part of a resync. + * Overloaded version of beforeUpdate method which is passed the + * storable in it's out-of-sync and sync'd states. The default + * implementation calls the inherited beforeUpdate method, only passing + * the newly sync'd storable. * - * @param newStorable storable which was inserted, never null + * @param oldStorable storable prior to being sync'd + * @param newStorable sync'd storable */ - void inserted(S newStorable); - - /** - * Called when a storable was updated as part of a resync. Both old and - * new storables have a matching primary key. - * - * @param oldStorable storable which was deleted, never null - * @param newStorable storable which was inserted, never null - */ - void updated(S oldStorable, S newStorable); - - /** - * Called when a storable was deleted as part of a resync. - * - * @param oldStorable storable which was deleted, never null - */ - void deleted(S oldStorable); + public Object beforeUpdate(S oldStorable, S newStorable) throws PersistException { + return beforeUpdate(newStorable); + } } } -- cgit v1.2.3