From 81475fd493bcc3d5fe750b54ce8d8fa9fb812c9c Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 8 Oct 2006 01:26:37 +0000 Subject: Finished support for trigger factories --- .../carbonado/spi/AbstractRepositoryBuilder.java | 24 ++++++++++------------ .../amazon/carbonado/spi/CommonMethodNames.java | 1 - .../amazon/carbonado/spi/StorableGenerator.java | 1 - .../com/amazon/carbonado/spi/WrappedQuery.java | 1 - .../com/amazon/carbonado/spi/WrappedStorage.java | 7 +++---- .../com/amazon/carbonado/spi/WrappedSupport.java | 1 - 6 files changed, 14 insertions(+), 21 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/spi') diff --git a/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java index d74c70a..ed4eaf3 100644 --- a/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java @@ -21,6 +21,7 @@ package com.amazon.carbonado.spi; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; import java.util.concurrent.atomic.AtomicReference; @@ -39,10 +40,10 @@ import com.amazon.carbonado.TriggerFactory; * @author Brian S O'Neill */ public abstract class AbstractRepositoryBuilder implements RepositoryBuilder { - private final List mTriggerFactories; + private final Collection mTriggerFactories; protected AbstractRepositoryBuilder() { - mTriggerFactories = new ArrayList(2); + mTriggerFactories = new LinkedHashSet(2); } public Repository build() throws ConfigurationException, RepositoryException { @@ -53,6 +54,14 @@ public abstract class AbstractRepositoryBuilder implements RepositoryBuilder { mTriggerFactories.add(factory); } + public Iterable getTriggerFactories() { + if (mTriggerFactories == null || mTriggerFactories.size() == 0) { + return Collections.emptyList(); + } else { + return new ArrayList(mTriggerFactories); + } + } + /** * Throw a configuration exception if the configuration is not filled out * sufficiently and correctly such that a repository could be instantiated @@ -91,15 +100,4 @@ public abstract class AbstractRepositoryBuilder implements RepositoryBuilder { messages.add("name missing"); } } - - /** - * Returns all the TriggerFactories which were added. - */ - protected Iterable getTriggerFactories() { - if (mTriggerFactories == null || mTriggerFactories.size() == 0) { - return Collections.emptyList(); - } else { - return new ArrayList(mTriggerFactories); - } - } } diff --git a/src/main/java/com/amazon/carbonado/spi/CommonMethodNames.java b/src/main/java/com/amazon/carbonado/spi/CommonMethodNames.java index c79e502..8a011c9 100644 --- a/src/main/java/com/amazon/carbonado/spi/CommonMethodNames.java +++ b/src/main/java/com/amazon/carbonado/spi/CommonMethodNames.java @@ -83,6 +83,5 @@ public class CommonMethodNames { EXIT_METHOD_NAME = "exit"; /** WrappedStorage.Support API method name */ - @Deprecated public static final String CREATE_WRAPPED_SUPPORT_METHOD_NAME = "createSupport"; } diff --git a/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java b/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java index f69d4dd..ecd344d 100644 --- a/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java @@ -357,7 +357,6 @@ public final class StorableGenerator { * @throws IllegalArgumentException if type is null */ @SuppressWarnings("unchecked") - @Deprecated public static Class getWrappedClass(Class type) throws IllegalArgumentException { diff --git a/src/main/java/com/amazon/carbonado/spi/WrappedQuery.java b/src/main/java/com/amazon/carbonado/spi/WrappedQuery.java index 531f38f..ec3ae34 100644 --- a/src/main/java/com/amazon/carbonado/spi/WrappedQuery.java +++ b/src/main/java/com/amazon/carbonado/spi/WrappedQuery.java @@ -36,7 +36,6 @@ import com.amazon.carbonado.filter.FilterValues; * @author Don Schneider * @author Brian S O'Neill */ -@Deprecated public abstract class WrappedQuery implements Query { // The query to which this query will delegate diff --git a/src/main/java/com/amazon/carbonado/spi/WrappedStorage.java b/src/main/java/com/amazon/carbonado/spi/WrappedStorage.java index 629cb53..1cefc73 100644 --- a/src/main/java/com/amazon/carbonado/spi/WrappedStorage.java +++ b/src/main/java/com/amazon/carbonado/spi/WrappedStorage.java @@ -25,6 +25,7 @@ import com.amazon.carbonado.Repository; import com.amazon.carbonado.Storable; import com.amazon.carbonado.Storage; import com.amazon.carbonado.Trigger; +import com.amazon.carbonado.TriggerFactory; import com.amazon.carbonado.filter.Filter; import com.amazon.carbonado.filter.FilterValues; @@ -39,7 +40,6 @@ import com.amazon.carbonado.util.QuickConstructorGenerator; * * @author Brian S O'Neill */ -@Deprecated public abstract class WrappedStorage implements Storage { private final Storage mStorage; private final WrappedStorableFactory mFactory; @@ -48,14 +48,13 @@ public abstract class WrappedStorage implements Storage { /** * @param storage storage to wrap */ - public WrappedStorage(Storage storage) { + public WrappedStorage(Storage storage, Iterable triggerFactories) { mStorage = storage; Class wrappedClass = StorableGenerator .getWrappedClass(storage.getStorableType()); mFactory = QuickConstructorGenerator .getInstance(wrappedClass, WrappedStorableFactory.class); - // FIXME: wrong, just deprecate this class - mTriggerManager = new TriggerManager(null, null); + mTriggerManager = new TriggerManager(storage.getStorableType(), triggerFactories); } public Class getStorableType() { diff --git a/src/main/java/com/amazon/carbonado/spi/WrappedSupport.java b/src/main/java/com/amazon/carbonado/spi/WrappedSupport.java index fa57c60..24e2c02 100644 --- a/src/main/java/com/amazon/carbonado/spi/WrappedSupport.java +++ b/src/main/java/com/amazon/carbonado/spi/WrappedSupport.java @@ -27,7 +27,6 @@ import com.amazon.carbonado.Storable; * * @author Brian S O'Neill */ -@Deprecated public interface WrappedSupport extends TriggerSupport { /** * @see Storable#load -- cgit v1.2.3