1 15 16 package com.jdon.controller.cache; 17 18 import java.util.*; 19 import com.jdon.util.Debug; 20 30 public abstract class CacheKeyFactory { 31 public final static String module = CacheKeyFactory.class.getName(); 32 33 protected CacheManager cacheManager; 34 35 public CacheKeyFactory(CacheManager cacheManager){ 36 this.cacheManager = cacheManager; 37 } 38 39 public CacheKey createCacheKey(Object dataKey, String typeName) { 40 CacheKey cacheKey = createCacheKeyImp(dataKey, typeName); 41 if (dataKey != null) 42 cacheManager.getCacheKeyMap().put(cacheKey.toString(), dataKey.toString()); 43 return cacheKey; 44 } 45 46 public abstract CacheKey createCacheKeyImp(Object dataKey, String typeName); 47 48 49 public void removeCacheKey(String cacheKeyStr){ 50 cacheManager.getCacheKeyMap().remove(cacheKeyStr); 51 } 52 53 58 public synchronized Collection getAllCacheKey(Object dataKey){ 59 60 String cacheKey = null; 61 String dataTmpKey = null; 62 Collection list = new ArrayList(); 63 64 Map map = cacheManager.getCacheKeyMap(); 65 Iterator iter = map.keySet().iterator(); 66 while(iter.hasNext()){ 67 cacheKey = (String )iter.next(); 68 dataTmpKey = (String )map.get(cacheKey); 69 if (dataTmpKey.equals(dataKey)){ 70 list.add(cacheKey); 71 } 72 } 73 return list; 74 } 75 76 77 } 78 | Popular Tags |