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. --- .../java/com/amazon/carbonado/gen/DelegateStorableGenerator.java | 7 ++++--- .../java/com/amazon/carbonado/gen/MasterStorableGenerator.java | 6 ++++-- src/main/java/com/amazon/carbonado/gen/StorablePropertyMap.java | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/gen') diff --git a/src/main/java/com/amazon/carbonado/gen/DelegateStorableGenerator.java b/src/main/java/com/amazon/carbonado/gen/DelegateStorableGenerator.java index 67e93f8..84b8c83 100644 --- a/src/main/java/com/amazon/carbonado/gen/DelegateStorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/gen/DelegateStorableGenerator.java @@ -29,11 +29,12 @@ import org.cojen.classfile.TypeDesc; import org.cojen.util.ClassInjector; import org.cojen.util.KeyFactory; -import org.cojen.util.SoftValuedHashMap; import com.amazon.carbonado.Storable; import com.amazon.carbonado.SupportException; +import com.amazon.carbonado.util.SoftValuedCache; + /** * Generates and caches concrete implementations of {@link Storable} types * which delegate to {@link DelegateSupport}. The delegating classes extend @@ -43,10 +44,10 @@ import com.amazon.carbonado.SupportException; * @since 1.2 */ public class DelegateStorableGenerator { - private static final Map cCache; + private static final SoftValuedCache cCache; static { - cCache = new SoftValuedHashMap(); + cCache = SoftValuedCache.newCache(11); } /** diff --git a/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java b/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java index 1c63d0c..ef73a2c 100644 --- a/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java @@ -38,7 +38,6 @@ import org.cojen.classfile.Opcode; import org.cojen.classfile.TypeDesc; import org.cojen.util.ClassInjector; import org.cojen.util.KeyFactory; -import org.cojen.util.SoftValuedHashMap; import com.amazon.carbonado.ConstraintException; import com.amazon.carbonado.IsolationLevel; @@ -55,6 +54,8 @@ import com.amazon.carbonado.info.StorableProperty; import com.amazon.carbonado.sequence.SequenceValueProducer; +import com.amazon.carbonado.util.SoftValuedCache; + import static com.amazon.carbonado.gen.CommonMethodNames.*; /** @@ -88,7 +89,8 @@ public final class MasterStorableGenerator { private static final String DELETE_OP = "Delete"; // Cache of generated abstract classes. - private static Map> cCache = new SoftValuedHashMap(); + private static SoftValuedCache> cCache = + SoftValuedCache.newCache(11); /** * Returns an abstract implementation of the given Storable type, which diff --git a/src/main/java/com/amazon/carbonado/gen/StorablePropertyMap.java b/src/main/java/com/amazon/carbonado/gen/StorablePropertyMap.java index 6ad3466..0b8086b 100644 --- a/src/main/java/com/amazon/carbonado/gen/StorablePropertyMap.java +++ b/src/main/java/com/amazon/carbonado/gen/StorablePropertyMap.java @@ -29,20 +29,20 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; -import org.cojen.util.SoftValuedHashMap; - import com.amazon.carbonado.Storable; import com.amazon.carbonado.info.StorableIntrospector; import com.amazon.carbonado.info.StorableProperty; +import com.amazon.carbonado.util.SoftValuedCache; + /** * Basic implementation for {@link Storable#propertyMap} method. * * @author Brian S O'Neill */ public class StorablePropertyMap extends AbstractMap { - private static final Map> cPropertyNamesForType = - new SoftValuedHashMap(); + private static final SoftValuedCache> cPropertyNamesForType = + SoftValuedCache.newCache(11); public static StorablePropertyMap createMap(Class type, S storable) { -- cgit v1.2.3