1 21 22 package com.rift.coad.lib.bean; 24 25 import java.util.Date ; 27 28 import com.rift.coad.lib.cache.CacheEntry; 30 31 36 public class BeanCacheEntry { 37 private long timeout = 0; 39 private Object cacheKey = null; 40 private Object wrappedObject = null; 41 private CacheEntry cacheEntry = null; 42 private Object proxy = null; 43 private CacheEntry beanHandler = null; 44 45 46 54 public BeanCacheEntry(long timeout, Object cacheKey, Object wrappedObject, 55 CacheEntry cacheEntry) { 56 this.timeout = timeout; 57 this.cacheKey = cacheKey; 58 this.wrappedObject = wrappedObject; 59 this.cacheEntry = cacheEntry; 60 } 61 62 63 71 public BeanCacheEntry(long timeout,Object cacheKey, Object wrappedObject, 72 Object proxy, CacheEntry beanHandler) { 73 this.timeout = timeout; 74 this.cacheKey = cacheKey; 75 this.wrappedObject = wrappedObject; 76 this.proxy = proxy; 77 this.beanHandler = beanHandler; 78 } 79 80 81 86 public Object getCacheKey() { 87 return cacheKey; 88 } 89 90 91 96 public Object getWrappedObject() { 97 return wrappedObject; 98 } 99 100 101 104 public CacheEntry getCacheEntry() { 105 return cacheEntry; 106 } 107 108 109 114 public void setCacheEntry(CacheEntry cacheEntry) { 115 this.cacheEntry = cacheEntry; 116 } 117 118 119 124 public Object getProxy() { 125 return proxy; 126 } 127 128 129 134 public void setProxy(Object proxy) { 135 this.proxy = proxy; 136 } 137 138 139 144 public CacheEntry getBeanHandler() { 145 return beanHandler; 146 } 147 148 149 154 public void setBeanHandler(CacheEntry beanHandler) { 155 this.beanHandler = beanHandler; 156 } 157 158 159 162 public void touch() { 163 if (cacheEntry != null){ 164 cacheEntry.touch(); 165 } 166 if (beanHandler != null) { 167 beanHandler.touch(); 168 } 169 } 170 171 172 178 public boolean isExpired(Date expiryDate) { 179 Date calculatedExpiryTime = new Date (expiryDate.getTime() - timeout); 180 if ((((cacheEntry != null) && 181 (cacheEntry.isExpired(calculatedExpiryTime))) || 182 (cacheEntry == null)) && ( (beanHandler == null) || 183 ((beanHandler != null) && 184 (beanHandler.isExpired(calculatedExpiryTime))) ) ) { 185 return true; 186 } 187 return false; 188 } 189 190 191 194 public void cacheRelease() { 195 if (cacheEntry != null){ 196 cacheEntry.cacheRelease(); 197 } 198 if (beanHandler != null) { 199 beanHandler.cacheRelease(); 200 } 201 } 202 } 203 | Popular Tags |