comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java @ 1060:cc4ec127d666

Remove the elements of an outdated state from cache if its endOfLife method is called. gnv-artifacts/trunk@1143 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 01 Jun 2010 16:54:21 +0000
parents c07d9f9a738c
children f953c9a559d8
comparison
equal deleted inserted replaced
1059:174f6eacd595 1060:cc4ec127d666
207 207
208 if (factory.isInitialized()) { 208 if (factory.isInitialized()) {
209 // we use a cache 209 // we use a cache
210 log.info("Using cache."); 210 log.info("Using cache.");
211 Cache cache = factory.getCache(); 211 Cache cache = factory.getCache();
212 String key = "chart_" + getHash(uuid); 212 String key = "chart_" + getHash();
213 213
214 net.sf.ehcache.Element value = cache.get(key); 214 net.sf.ehcache.Element value = cache.get(key);
215 if (value != null) { 215 if (value != null) {
216 log.debug("Found element in cache."); 216 log.debug("Found element in cache.");
217 return value.getObjectValue(); 217 return value.getObjectValue();
240 */ 240 */
241 protected Object getChartFromCache(String uuid, CallContext callContext) { 241 protected Object getChartFromCache(String uuid, CallContext callContext) {
242 log.debug("Fetch chart [" + uuid + "] from cache"); 242 log.debug("Fetch chart [" + uuid + "] from cache");
243 CacheFactory cacheFactory = CacheFactory.getInstance(); 243 CacheFactory cacheFactory = CacheFactory.getInstance();
244 if (cacheFactory.isInitialized()) { 244 if (cacheFactory.isInitialized()) {
245 String key = "chart_" + getHash(uuid); 245 String key = "chart_" + getHash();
246 net.sf.ehcache.Element object = cacheFactory.getCache().get(key); 246 net.sf.ehcache.Element object = cacheFactory.getCache().get(key);
247 247
248 if (object != null) { 248 if (object != null) {
249 return object.getObjectValue(); 249 return object.getObjectValue();
250 } 250 }
300 * 300 *
301 */ 301 */
302 protected void removeChartResult(String uuid) { 302 protected void removeChartResult(String uuid) {
303 log.debug("OutputStateBase.getChartResult"); 303 log.debug("OutputStateBase.getChartResult");
304 if (CacheFactory.getInstance().isInitialized()) { 304 if (CacheFactory.getInstance().isInitialized()) {
305 String key = "chart_" + getHash(uuid); 305 String key = "chart_" + getHash();
306 log.debug("Hash for Queryelements: " + key); 306 log.debug("Hash for Queryelements: " + key);
307 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key); 307 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key);
308 if (value != null) { 308 if (value != null) {
309 CacheFactory.getInstance().getCache().remove(key); 309 CacheFactory.getInstance().getCache().remove(key);
310 } 310 }
319 protected void removeChart(String uuid) { 319 protected void removeChart(String uuid) {
320 log.debug("OutputStateBase.removeChart from cache"); 320 log.debug("OutputStateBase.removeChart from cache");
321 321
322 CacheFactory cacheFactory = CacheFactory.getInstance(); 322 CacheFactory cacheFactory = CacheFactory.getInstance();
323 if (cacheFactory.isInitialized()) { 323 if (cacheFactory.isInitialized()) {
324 String key = "chart_" + getHash(uuid); 324 String key = "chart_" + getHash();
325 net.sf.ehcache.Element object = cacheFactory.getCache().get(key); 325 net.sf.ehcache.Element object = cacheFactory.getCache().get(key);
326 if (object != null) 326 if (object != null)
327 cacheFactory.getCache().remove(key); 327 cacheFactory.getCache().remove(key);
328 } 328 }
329 } 329 }
333 */ 333 */
334 protected void purifyChart(Object chart, String uuid) { 334 protected void purifyChart(Object chart, String uuid) {
335 log.debug("Prufify chart [" + uuid + "]"); 335 log.debug("Prufify chart [" + uuid + "]");
336 CacheFactory cacheFactory = CacheFactory.getInstance(); 336 CacheFactory cacheFactory = CacheFactory.getInstance();
337 if (cacheFactory.isInitialized()) { 337 if (cacheFactory.isInitialized()) {
338 String key = "chart_" + getHash(uuid); 338 String key = "chart_" + getHash();
339 cacheFactory.getCache().put(new net.sf.ehcache.Element(key, chart)); 339 cacheFactory.getCache().put(new net.sf.ehcache.Element(key, chart));
340 } 340 }
341 } 341 }
342 342
343 343

http://dive4elements.wald.intevation.org