# HG changeset patch # User Ingo Weinzierl # Date 1267088796 0 # Node ID 62ea2a7b10673e243a4b1898c204789e1c605fa1 # Parent f4331a0df032b18784df00f7480b242a1d4ae6d0 'Profilschnitte' are working without cache as well, now. gnv-artifacts/trunk@711 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f4331a0df032 -r 62ea2a7b1067 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Thu Feb 25 08:23:46 2010 +0000 +++ b/gnv-artifacts/ChangeLog Thu Feb 25 09:06:36 2010 +0000 @@ -1,3 +1,15 @@ +2010-02-25 Ingo Weinzierl + + * src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java: + Changed the way of using cache to store verticalcrosssection chart data. + Now, this type of chart is working without cache, as well. + +2010-02-25 Ingo Weinzierl + + * src/main/java/de/intevation/gnv/state/OutputStateBase.java: Changed the + way of using the cache to store chart / histogram data. Now, output modes + 'chart' and 'histogram' are working without cache. + 2010-02-25 Ingo Weinzierl * src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java: diff -r f4331a0df032 -r 62ea2a7b1067 gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java Thu Feb 25 08:23:46 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java Thu Feb 25 09:06:36 2010 +0000 @@ -76,6 +76,7 @@ import java.util.Locale; import java.util.Map; +import net.sf.ehcache.Cache; import net.sf.ehcache.Element; import org.apache.log4j.Logger; @@ -171,17 +172,34 @@ @Override protected Object getChartResult(String uuid, CallContext callContext) { log.debug("VerticalCrossSectionOutputState.getChartResult"); - Collection result = null; String key = uuid + super.getID(); - Element element = CacheFactory.getInstance().getCache().get(key); - if (element != null) - return element.getObjectValue(); + CacheFactory factory = CacheFactory.getInstance(); + if (factory.isInitialized()) { + log.info("Using a cachce."); + Cache cache = factory.getCache(); - log.debug("No results in cache yet."); + Element element = cache.get(key); + if (element != null) + return element.getObjectValue(); - InputData meshLine = inputData.get("mesh_linestring"); - InputData meshId = inputData.get("meshid"); + log.debug("No results in cache yet."); + Object obj = getData(uuid, callContext); + cache.put(new Element(key, obj)); + + return obj; + } + else { + log.info("Not using a cache."); + return getData(uuid, callContext); + } + } + + + protected Object getData(String uuid, CallContext callContext) { + Collection result = null; + InputData meshLine = inputData.get("mesh_linestring"); + InputData meshId = inputData.get("meshid"); if (meshLine == null) { log.error("mesh_linestring is not defined"); @@ -228,8 +246,6 @@ preProcess(result), callContext); - CacheFactory.getInstance().getCache().put(new Element(key, obj)); - return obj; }