diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2006-10-07 22:27:25 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2006-10-07 22:27:25 +0000 |
commit | 6dd20a4b23592c0a9a6be23a2123fef410981a2e (patch) | |
tree | 2af894f5335c26115d2f92cdf26d01614dfdc1b6 /src/main/java/com/amazon/carbonado/spi | |
parent | ebc282a22ddc2cb97bc1af4fe3fa0fedc290fe1b (diff) |
Added TriggerFactory.
Deprecated wrapped storage and query.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/spi')
7 files changed, 43 insertions, 2 deletions
diff --git a/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java index a8f0169..d74c70a 100644 --- a/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java @@ -20,6 +20,8 @@ package com.amazon.carbonado.spi; import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@@ -27,6 +29,8 @@ import com.amazon.carbonado.ConfigurationException; import com.amazon.carbonado.Repository;
import com.amazon.carbonado.RepositoryBuilder;
import com.amazon.carbonado.RepositoryException;
+import com.amazon.carbonado.Trigger;
+import com.amazon.carbonado.TriggerFactory;
/**
* Abstract builder class for opening repositories.
@@ -35,13 +39,20 @@ import com.amazon.carbonado.RepositoryException; * @author Brian S O'Neill
*/
public abstract class AbstractRepositoryBuilder implements RepositoryBuilder {
+ private final List<TriggerFactory> mTriggerFactories;
+
protected AbstractRepositoryBuilder() {
+ mTriggerFactories = new ArrayList<TriggerFactory>(2);
}
public Repository build() throws ConfigurationException, RepositoryException {
return build(new AtomicReference<Repository>());
}
+ public void addTriggerFactory(TriggerFactory factory) {
+ mTriggerFactories.add(factory);
+ }
+
/**
* Throw a configuration exception if the configuration is not filled out
* sufficiently and correctly such that a repository could be instantiated
@@ -80,4 +91,15 @@ public abstract class AbstractRepositoryBuilder implements RepositoryBuilder { messages.add("name missing");
}
}
+
+ /**
+ * Returns all the TriggerFactories which were added.
+ */
+ protected Iterable<TriggerFactory> getTriggerFactories() {
+ if (mTriggerFactories == null || mTriggerFactories.size() == 0) {
+ return Collections.emptyList();
+ } else {
+ return new ArrayList<TriggerFactory>(mTriggerFactories);
+ }
+ }
}
diff --git a/src/main/java/com/amazon/carbonado/spi/CommonMethodNames.java b/src/main/java/com/amazon/carbonado/spi/CommonMethodNames.java index 8a011c9..c79e502 100644 --- a/src/main/java/com/amazon/carbonado/spi/CommonMethodNames.java +++ b/src/main/java/com/amazon/carbonado/spi/CommonMethodNames.java @@ -83,5 +83,6 @@ 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 ecd344d..f69d4dd 100644 --- a/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java @@ -357,6 +357,7 @@ public final class StorableGenerator<S extends Storable> { * @throws IllegalArgumentException if type is null
*/
@SuppressWarnings("unchecked")
+ @Deprecated
public static <S extends Storable> Class<? extends S> getWrappedClass(Class<S> type)
throws IllegalArgumentException
{
diff --git a/src/main/java/com/amazon/carbonado/spi/TriggerManager.java b/src/main/java/com/amazon/carbonado/spi/TriggerManager.java index cabf526..60661d1 100644 --- a/src/main/java/com/amazon/carbonado/spi/TriggerManager.java +++ b/src/main/java/com/amazon/carbonado/spi/TriggerManager.java @@ -26,6 +26,7 @@ import java.util.Arrays; import com.amazon.carbonado.PersistException;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.Trigger;
+import com.amazon.carbonado.TriggerFactory;
/**
* Used by Storage implementations to manage triggers and consolidate them into
@@ -93,7 +94,19 @@ public class TriggerManager<S extends Storable> { private volatile ForUpdate<S> mForUpdate;
private volatile ForDelete<S> mForDelete;
- public TriggerManager() {
+ /**
+ * @param triggerFactories TriggerFactories which will be called upon to
+ * optionally return a trigger to initially register
+ */
+ public TriggerManager(Class<S> type, Iterable<TriggerFactory> triggerFactories) {
+ if (triggerFactories != null) {
+ for (TriggerFactory factory : triggerFactories) {
+ Trigger<? super S> trigger = factory.triggerFor(type);
+ if (trigger != null) {
+ addTrigger(trigger);
+ }
+ }
+ }
}
/**
diff --git a/src/main/java/com/amazon/carbonado/spi/WrappedQuery.java b/src/main/java/com/amazon/carbonado/spi/WrappedQuery.java index ec3ae34..531f38f 100644 --- a/src/main/java/com/amazon/carbonado/spi/WrappedQuery.java +++ b/src/main/java/com/amazon/carbonado/spi/WrappedQuery.java @@ -36,6 +36,7 @@ import com.amazon.carbonado.filter.FilterValues; * @author Don Schneider
* @author Brian S O'Neill
*/
+@Deprecated
public abstract class WrappedQuery<S extends Storable> implements Query<S> {
// 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 598e889..629cb53 100644 --- a/src/main/java/com/amazon/carbonado/spi/WrappedStorage.java +++ b/src/main/java/com/amazon/carbonado/spi/WrappedStorage.java @@ -39,6 +39,7 @@ import com.amazon.carbonado.util.QuickConstructorGenerator; *
* @author Brian S O'Neill
*/
+@Deprecated
public abstract class WrappedStorage<S extends Storable> implements Storage<S> {
private final Storage<S> mStorage;
private final WrappedStorableFactory<S> mFactory;
@@ -53,7 +54,8 @@ public abstract class WrappedStorage<S extends Storable> implements Storage<S> { .getWrappedClass(storage.getStorableType());
mFactory = QuickConstructorGenerator
.getInstance(wrappedClass, WrappedStorableFactory.class);
- mTriggerManager = new TriggerManager<S>();
+ // FIXME: wrong, just deprecate this class
+ mTriggerManager = new TriggerManager<S>(null, null);
}
public Class<S> getStorableType() {
diff --git a/src/main/java/com/amazon/carbonado/spi/WrappedSupport.java b/src/main/java/com/amazon/carbonado/spi/WrappedSupport.java index 24e2c02..fa57c60 100644 --- a/src/main/java/com/amazon/carbonado/spi/WrappedSupport.java +++ b/src/main/java/com/amazon/carbonado/spi/WrappedSupport.java @@ -27,6 +27,7 @@ import com.amazon.carbonado.Storable; *
* @author Brian S O'Neill
*/
+@Deprecated
public interface WrappedSupport<S extends Storable> extends TriggerSupport<S> {
/**
* @see Storable#load
|