diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2010-08-18 16:54:59 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2010-08-18 16:54:59 +0000 |
commit | c270234f37f0d9bdb1755f22561cbcba156b6e8c (patch) | |
tree | 1c1d2b14e7b9d383945c050425575802ab7aa782 /src/main/java/com/amazon/carbonado/gen | |
parent | 41baed7d94d0cef87d77bd9dbdac78940a71180a (diff) |
Introduce SoftValuedCache, which evicts more aggressively than SoftValuedHashMap.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/gen')
3 files changed, 12 insertions, 9 deletions
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<S extends Storable> {
- private static final Map<Object, Class> cCache;
+ private static final SoftValuedCache<Object, Class> 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<S extends Storable> { private static final String DELETE_OP = "Delete";
// Cache of generated abstract classes.
- private static Map<Object, Class<? extends Storable>> cCache = new SoftValuedHashMap();
+ private static SoftValuedCache<Object, Class<? extends Storable>> 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<S extends Storable> extends AbstractMap<String, Object> {
- private static final Map<Class, Set<String>> cPropertyNamesForType =
- new SoftValuedHashMap();
+ private static final SoftValuedCache<Class, Set<String>> cPropertyNamesForType =
+ SoftValuedCache.newCache(11);
public static <S extends Storable> StorablePropertyMap<S> createMap(Class<S> type, S storable)
{
|