summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/layout
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2010-08-18 16:54:59 +0000
committerBrian S. O'Neill <bronee@gmail.com>2010-08-18 16:54:59 +0000
commitc270234f37f0d9bdb1755f22561cbcba156b6e8c (patch)
tree1c1d2b14e7b9d383945c050425575802ab7aa782 /src/main/java/com/amazon/carbonado/layout
parent41baed7d94d0cef87d77bd9dbdac78940a71180a (diff)
Introduce SoftValuedCache, which evicts more aggressively than SoftValuedHashMap.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/layout')
-rw-r--r--src/main/java/com/amazon/carbonado/layout/Layout.java7
-rw-r--r--src/main/java/com/amazon/carbonado/layout/LayoutFactory.java8
2 files changed, 7 insertions, 8 deletions
diff --git a/src/main/java/com/amazon/carbonado/layout/Layout.java b/src/main/java/com/amazon/carbonado/layout/Layout.java
index 98df22c..6c28740 100644
--- a/src/main/java/com/amazon/carbonado/layout/Layout.java
+++ b/src/main/java/com/amazon/carbonado/layout/Layout.java
@@ -35,8 +35,6 @@ import org.joda.time.DateTime;
import org.apache.commons.logging.LogFactory;
-import org.cojen.util.SoftValuedHashMap;
-
import com.amazon.carbonado.CorruptEncodingException;
import com.amazon.carbonado.Cursor;
import com.amazon.carbonado.FetchException;
@@ -53,6 +51,7 @@ import com.amazon.carbonado.synthetic.SyntheticKey;
import com.amazon.carbonado.synthetic.SyntheticProperty;
import com.amazon.carbonado.synthetic.SyntheticStorableBuilder;
import com.amazon.carbonado.util.AnnotationDescPrinter;
+import com.amazon.carbonado.util.SoftValuedCache;
import com.amazon.carbonado.capability.ResyncCapability;
@@ -63,10 +62,10 @@ import com.amazon.carbonado.capability.ResyncCapability;
* @see LayoutFactory
*/
public class Layout {
- private static Map<Long, Class<? extends Storable>> cReconstructed;
+ private static SoftValuedCache<Long, Class<? extends Storable>> cReconstructed;
static {
- cReconstructed = Collections.synchronizedMap(new SoftValuedHashMap());
+ cReconstructed = SoftValuedCache.newCache(7);
}
static Class<? extends Storable> reconstruct(final Layout layout, ClassLoader loader)
diff --git a/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java b/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java
index 7b7953b..836ee54 100644
--- a/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java
+++ b/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java
@@ -29,8 +29,6 @@ import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Map;
-import org.cojen.util.SoftValuedHashMap;
-
import com.amazon.carbonado.Cursor;
import com.amazon.carbonado.FetchDeadlockException;
import com.amazon.carbonado.FetchException;
@@ -55,6 +53,8 @@ import com.amazon.carbonado.info.StorableProperty;
import com.amazon.carbonado.info.StorablePropertyAdapter;
import com.amazon.carbonado.info.StorablePropertyAnnotation;
+import com.amazon.carbonado.util.SoftValuedCache;
+
/**
* Factory for obtaining references to storable layouts.
*
@@ -69,7 +69,7 @@ public class LayoutFactory implements LayoutCapability {
final Storage<StoredLayout> mLayoutStorage;
final Storage<StoredLayoutProperty> mPropertyStorage;
- private Map<Class<? extends Storable>, Layout> mReconstructed;
+ private SoftValuedCache<Class<? extends Storable>, Layout> mReconstructed;
/**
* @throws com.amazon.carbonado.SupportException if underlying repository
@@ -339,7 +339,7 @@ public class LayoutFactory implements LayoutCapability {
(Class<? extends Storable> reconstructed, Layout layout)
{
if (mReconstructed == null) {
- mReconstructed = new SoftValuedHashMap();
+ mReconstructed = SoftValuedCache.newCache(7);
}
mReconstructed.put(reconstructed, layout);
}