Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java @ 1030:c07d9f9a738c
Removed bugs that existed in the caching mechanism (issue264, issue268).
gnv-artifacts/trunk@1067 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 06 May 2010 08:32:56 +0000 |
parents | 499cfbbb61bc |
children | cc4ec127d666 |
comparison
equal
deleted
inserted
replaced
1029:a5e0384fe464 | 1030:c07d9f9a738c |
---|---|
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(); | 212 String key = "chart_" + getHash(uuid); |
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(); | 245 String key = "chart_" + getHash(uuid); |
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(); | 305 String key = "chart_" + getHash(uuid); |
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(); | 324 String key = "chart_" + getHash(uuid); |
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(); | 338 String key = "chart_" + getHash(uuid); |
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 |