1 package org.jboss.cache.eviction; 2 3 import org.jboss.cache.CacheException; 4 import org.jboss.cache.CacheImpl; 5 import org.jboss.cache.Fqn; 6 import org.jboss.cache.NodeSPI; 7 8 import java.util.Set ; 9 10 17 public abstract class BaseEvictionPolicy implements EvictionPolicy 18 { 19 protected CacheImpl cache_; 20 21 public BaseEvictionPolicy() 22 { 23 } 24 25 26 27 33 public void evict(Fqn fqn) throws Exception 34 { 35 cache_.evict(fqn); 36 } 37 38 44 public Set getChildrenNames(Fqn fqn) 45 { 46 try 47 { 48 return cache_.getChildrenNames(fqn); 49 } 50 catch (CacheException e) 51 { 52 e.printStackTrace(); 53 } 54 return null; 55 } 56 57 public boolean hasChild(Fqn fqn) 58 { 59 return cache_.hasChild(fqn); 60 } 61 62 public Object getCacheData(Fqn fqn, Object key) 63 { 64 try 65 { 66 NodeSPI n = cache_.peek(fqn); 67 if (n == null) 68 { 69 return null; 70 } 71 72 return n.getDirect(key); 73 } 74 catch (CacheException e) 75 { 76 throw new CacheException("Failed locating key for " + fqn, e); 77 } 78 } 79 80 public void configure(CacheImpl cache) 81 { 82 this.cache_ = cache; 83 } 84 85 90 public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType) 91 { 92 return false; 93 } 94 } 95 | Popular Tags |