summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo/logging
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2006-10-15 17:50:08 +0000
committerBrian S. O'Neill <bronee@gmail.com>2006-10-15 17:50:08 +0000
commitf0ec30fd9cc7fa19f9f9bf82d7d7449a65d90359 (patch)
treeffb5f5fecb4282f1bdb6e8bbb3e572f256310a70 /src/main/java/com/amazon/carbonado/repo/logging
parent4ceddfc456e83a79e782599b5b86b68e38b6ef94 (diff)
Created StorageCollection.
More tests added.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/logging')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/logging/LoggingRepository.java25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepository.java b/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepository.java
index 99c462c..58639e2 100644
--- a/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepository.java
+++ b/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepository.java
@@ -18,9 +18,6 @@
package com.amazon.carbonado.repo.logging;
-import java.util.IdentityHashMap;
-import java.util.Map;
-
import java.util.concurrent.atomic.AtomicReference;
import com.amazon.carbonado.IsolationLevel;
@@ -34,6 +31,8 @@ import com.amazon.carbonado.TriggerFactory;
import com.amazon.carbonado.capability.Capability;
+import com.amazon.carbonado.spi.StorageCollection;
+
/**
*
*
@@ -45,8 +44,7 @@ class LoggingRepository implements Repository, LogAccessCapability {
private final Repository mRepo;
private final Log mLog;
- // Map of storages by storable class
- private final Map<Class<?>, LoggingStorage<?>> mStorages;
+ private final StorageCollection mStorages;
LoggingRepository(AtomicReference<Repository> rootRef,
Iterable<TriggerFactory> triggerFactories,
@@ -57,7 +55,13 @@ class LoggingRepository implements Repository, LogAccessCapability {
mRepo = actual;
mLog = log;
- mStorages = new IdentityHashMap<Class<?>, LoggingStorage<?>>();
+ mStorages = new StorageCollection() {
+ protected <S extends Storable> Storage<S> createStorage(Class<S> type)
+ throws RepositoryException
+ {
+ return new LoggingStorage(LoggingRepository.this, mRepo.storageFor(type));
+ }
+ };
}
public String getName() {
@@ -67,14 +71,7 @@ class LoggingRepository implements Repository, LogAccessCapability {
public <S extends Storable> Storage<S> storageFor(Class<S> type)
throws SupportException, RepositoryException
{
- synchronized (mStorages) {
- LoggingStorage storage = mStorages.get(type);
- if (storage == null) {
- storage = new LoggingStorage(this, mRepo.storageFor(type));
- mStorages.put(type, storage);
- }
- return storage;
- }
+ return mStorages.storageFor(type);
}
public Transaction enterTransaction() {