1 16 package com.ibatis.sqlmap.engine.cache.memory; 17 18 import com.ibatis.sqlmap.client.SqlMapException; 19 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 26 public final class MemoryCacheLevel { 27 28 private static Map cacheLevelMap = new HashMap (); 29 30 37 public final static MemoryCacheLevel WEAK; 38 39 46 public final static MemoryCacheLevel SOFT; 47 48 62 public final static MemoryCacheLevel STRONG; 63 64 private String referenceType; 65 66 static { 67 WEAK = new MemoryCacheLevel("WEAK"); 68 SOFT = new MemoryCacheLevel("SOFT"); 69 STRONG = new MemoryCacheLevel("STRONG"); 70 71 cacheLevelMap.put(WEAK.referenceType, WEAK); 72 cacheLevelMap.put(SOFT.referenceType, SOFT); 73 cacheLevelMap.put(STRONG.referenceType, STRONG); 74 } 75 76 77 80 private MemoryCacheLevel(String type) { 81 this.referenceType = type; 82 } 83 84 89 public String getReferenceType() { 90 return this.referenceType; 91 } 92 93 99 public static MemoryCacheLevel getByReferenceType(String refType) { 100 MemoryCacheLevel cacheLevel = (MemoryCacheLevel) cacheLevelMap.get(refType); 101 if (cacheLevel == null) { 102 throw new SqlMapException("Error getting CacheLevel (reference type) for name: '" + refType + "'."); 103 } 104 return cacheLevel; 105 } 106 } 107 108 | Popular Tags |