1 package org.shiftone.cache.decorator.tandem; 2 3 4 5 import org.shiftone.cache.util.Log; 6 import org.shiftone.cache.CacheFactory; 7 import org.shiftone.cache.Cache; 8 9 10 15 public class TandemCacheFactory implements CacheFactory 16 { 17 18 private static final Log LOG = new Log(TandemCacheFactory.class); 19 private boolean allGets = true; 20 private CacheFactory delegateA; 21 private CacheFactory delegateB; 22 23 public Cache newInstance(String cacheName, long timeoutMilliSeconds, int maxSize) 24 { 25 26 Cache cacheA = delegateA.newInstance(cacheName, timeoutMilliSeconds, maxSize); 27 Cache cacheB = delegateB.newInstance(cacheName, timeoutMilliSeconds, maxSize); 28 Cache[] caches = { cacheA, cacheB }; 29 30 return (allGets) 31 ? new TandemAllGetsCache(caches) 32 : new TandemCache(caches); 33 } 34 35 36 public boolean isAllGets() 37 { 38 return allGets; 39 } 40 41 42 public void setAllGets(boolean allGets) 43 { 44 this.allGets = allGets; 45 } 46 47 48 public CacheFactory getDelegateA() 49 { 50 return delegateA; 51 } 52 53 54 public void setDelegateA(CacheFactory delegateA) 55 { 56 this.delegateA = delegateA; 57 } 58 59 60 public CacheFactory getDelegateB() 61 { 62 return delegateB; 63 } 64 65 66 public void setDelegateB(CacheFactory delegateB) 67 { 68 this.delegateB = delegateB; 69 } 70 } 71 | Popular Tags |