From 6d231091ddf24f5c05e51b8c48e455b09dab47c8 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 26 Aug 2007 01:26:13 +0000 Subject: Removed Trigger lob adapting methods. --- src/main/java/com/amazon/carbonado/Trigger.java | 35 --------- .../carbonado/repo/sleepycat/BDBStorage.java | 14 +--- .../com/amazon/carbonado/spi/TriggerManager.java | 85 +--------------------- 3 files changed, 3 insertions(+), 131 deletions(-) diff --git a/src/main/java/com/amazon/carbonado/Trigger.java b/src/main/java/com/amazon/carbonado/Trigger.java index 4b6041c..d974313 100644 --- a/src/main/java/com/amazon/carbonado/Trigger.java +++ b/src/main/java/com/amazon/carbonado/Trigger.java @@ -18,9 +18,6 @@ package com.amazon.carbonado; -import com.amazon.carbonado.lob.Blob; -import com.amazon.carbonado.lob.Clob; - /** * Callback mechanism to allow custom code to run when a storable is * persisted. By default, the methods defined in this class do @@ -296,38 +293,6 @@ public abstract class Trigger { public void afterLoad(S storable) throws FetchException { } - /** - * Called after a Blob is loaded. Override to return an adapted Blob which - * can listen for changes. By default, the original Blob is returned - * unmodified. - * - * @param storable storable which contains Blob property - * @param name property name of Blob - * @param blob non-null Blob property instance - * @return adapted Blob - * @since 1.2 - * @deprecated use afterLoad instead to adapt Blobs - */ - public Blob adaptBlob(S storable, String name, Blob blob) { - return blob; - } - - /** - * Called after a Clob is loaded. Override to return an adapted Clob which - * can listen for changes. By default, the original Clob is returned - * unmodified. - * - * @param storable storable which contains Clob property - * @param name property name of Clob - * @param clob non-null Clob property instance - * @return adapted Clob - * @since 1.2 - * @deprecated use afterLoad instead to adapt Clobs - */ - public Clob adaptClob(S storable, String name, Clob clob) { - return clob; - } - /** * Call to quickly abort a "try" operation, returning false to the * caller. This method should not be called by a non-try trigger method, diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java index 1f14c4f..0b9f53c 100644 --- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java +++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java @@ -686,12 +686,7 @@ abstract class BDBStorage implements Storage, Storag Blob getBlob(S storable, String name, long locator) throws FetchException { try { - Blob blob = mRepository.getLobEngine().getBlobValue(locator); - Trigger trigger = mTriggerManager.getAdaptLobTrigger(); - if (trigger != null) { - blob = trigger.adaptBlob(storable, name, blob); - } - return blob; + return mRepository.getLobEngine().getBlobValue(locator); } catch (RepositoryException e) { throw e.toFetchException(); } @@ -709,12 +704,7 @@ abstract class BDBStorage implements Storage, Storag Clob getClob(S storable, String name, long locator) throws FetchException { try { - Clob clob = mRepository.getLobEngine().getClobValue(locator); - Trigger trigger = mTriggerManager.getAdaptLobTrigger(); - if (trigger != null) { - clob = trigger.adaptClob(storable, name, clob); - } - return clob; + return mRepository.getLobEngine().getClobValue(locator); } catch (RepositoryException e) { throw e.toFetchException(); } diff --git a/src/main/java/com/amazon/carbonado/spi/TriggerManager.java b/src/main/java/com/amazon/carbonado/spi/TriggerManager.java index e7b653c..46747ea 100644 --- a/src/main/java/com/amazon/carbonado/spi/TriggerManager.java +++ b/src/main/java/com/amazon/carbonado/spi/TriggerManager.java @@ -33,9 +33,6 @@ import com.amazon.carbonado.Storable; import com.amazon.carbonado.Trigger; import com.amazon.carbonado.TriggerFactory; -import com.amazon.carbonado.lob.Blob; -import com.amazon.carbonado.lob.Clob; - /** * Used by Storage implementations to manage triggers and consolidate them into * single logical triggers. This class is thread-safe and ensures that changes @@ -49,7 +46,6 @@ public class TriggerManager extends Trigger { private static final int FOR_UPDATE = 2; private static final int FOR_DELETE = 4; private static final int FOR_LOAD = 8; - private static final int FOR_ADAPT_LOB = 16; private static final Method BEFORE_INSERT_METHOD, @@ -70,10 +66,7 @@ public class TriggerManager extends Trigger { AFTER_TRY_DELETE_METHOD, FAILED_DELETE_METHOD, - AFTER_LOAD_METHOD, - - ADAPT_BLOB_METHOD, - ADAPT_CLOB_METHOD; + AFTER_LOAD_METHOD; static { Class triggerClass = Trigger.class; @@ -100,11 +93,6 @@ public class TriggerManager extends Trigger { FAILED_DELETE_METHOD = triggerClass.getMethod("failedDelete", TWO_PARAMS); AFTER_LOAD_METHOD = triggerClass.getMethod("afterLoad", ONE_PARAM); - - ADAPT_BLOB_METHOD = triggerClass - .getMethod("adaptBlob", Object.class, String.class, Blob.class); - ADAPT_CLOB_METHOD = triggerClass - .getMethod("adaptClob", Object.class, String.class, Clob.class); } catch (NoSuchMethodException e) { Error error = new NoSuchMethodError(); error.initCause(e); @@ -116,7 +104,6 @@ public class TriggerManager extends Trigger { private final ForUpdate mForUpdate = new ForUpdate(); private final ForDelete mForDelete = new ForDelete(); private final ForLoad mForLoad = new ForLoad(); - private final ForAdaptLob mForAdaptLob = new ForAdaptLob(); public TriggerManager() { } @@ -175,18 +162,6 @@ public class TriggerManager extends Trigger { return forLoad.isEmpty() ? null : forLoad; } - /** - * Returns a consolidated trigger to call for adapt LOB operations, or null - * if none. If not null, the consolidated trigger is not a snapshot -- it - * will change as the set of triggers in this manager changes. - * - * @since 1.2 - */ - public Trigger getAdaptLobTrigger() { - ForAdaptLob forAdaptLob = mForAdaptLob; - return forAdaptLob.isEmpty() ? null : forAdaptLob; - } - public boolean addTrigger(Trigger trigger) { if (trigger == null) { throw new IllegalArgumentException(); @@ -208,9 +183,6 @@ public class TriggerManager extends Trigger { if ((types & FOR_LOAD) != 0) { retValue |= mForLoad.add(trigger); } - if ((types & FOR_ADAPT_LOB) != 0) { - retValue |= mForAdaptLob.add(trigger); - } return retValue; } @@ -236,9 +208,6 @@ public class TriggerManager extends Trigger { if ((types & FOR_LOAD) != 0) { retValue |= mForLoad.remove(trigger); } - if ((types & FOR_ADAPT_LOB) != 0) { - retValue |= mForAdaptLob.remove(trigger); - } return retValue; } @@ -422,16 +391,6 @@ public class TriggerManager extends Trigger { mForLoad.afterLoad(storable); } - @Override - public Blob adaptBlob(S storable, String name, Blob blob) { - return mForAdaptLob.adaptBlob(storable, name, blob); - } - - @Override - public Clob adaptClob(S storable, String name, Clob clob) { - return mForAdaptLob.adaptClob(storable, name, clob); - } - /** * Determines which operations the given trigger overrides. */ @@ -471,12 +430,6 @@ public class TriggerManager extends Trigger { types |= FOR_LOAD; } - if (overridesMethod(triggerClass, ADAPT_BLOB_METHOD) || - overridesMethod(triggerClass, ADAPT_CLOB_METHOD)) - { - types |= FOR_ADAPT_LOB; - } - return types; } @@ -1057,40 +1010,4 @@ public class TriggerManager extends Trigger { } } } - - private static class ForAdaptLob extends ManagedTrigger { - @Override - public Blob adaptBlob(S storable, String name, Blob blob) { - if (isLocallyDisabled()) { - return blob; - } - - Trigger[] triggers = mTriggers; - - int length = triggers.length; - - for (int i=0; i[] triggers = mTriggers; - - int length = triggers.length; - - for (int i=0; i