From c270234f37f0d9bdb1755f22561cbcba156b6e8c Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Wed, 18 Aug 2010 16:54:59 +0000 Subject: Introduce SoftValuedCache, which evicts more aggressively than SoftValuedHashMap. --- src/main/java/com/amazon/carbonado/layout/Layout.java | 7 +++---- src/main/java/com/amazon/carbonado/layout/LayoutFactory.java | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/layout') 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> cReconstructed; + private static SoftValuedCache> cReconstructed; static { - cReconstructed = Collections.synchronizedMap(new SoftValuedHashMap()); + cReconstructed = SoftValuedCache.newCache(7); } static Class 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 mLayoutStorage; final Storage mPropertyStorage; - private Map, Layout> mReconstructed; + private SoftValuedCache, Layout> mReconstructed; /** * @throws com.amazon.carbonado.SupportException if underlying repository @@ -339,7 +339,7 @@ public class LayoutFactory implements LayoutCapability { (Class reconstructed, Layout layout) { if (mReconstructed == null) { - mReconstructed = new SoftValuedHashMap(); + mReconstructed = SoftValuedCache.newCache(7); } mReconstructed.put(reconstructed, layout); } -- cgit v1.2.3