Mercurial > dive4elements > gnv-client
changeset 621:567216b56983
Added MapfileGenerator stub and MapfileGenerator calls after writing and removing shapefiles.
gnv-artifacts/trunk@692 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 17 Feb 2010 09:40:15 +0000 |
parents | f668c881f45a |
children | 89aca25642d6 |
files | gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/conf.xml gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java |
diffstat | 4 files changed, 104 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Tue Feb 16 11:01:59 2010 +0000 +++ b/gnv-artifacts/ChangeLog Wed Feb 17 09:40:15 2010 +0000 @@ -1,3 +1,19 @@ +2010-02-17 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + * doc/conf/conf.xml: Added configuration section for writing mapfiles. + + * src/main/java/de/intevation/gnv/utils/MapfileGenerator.java: Singleton + generator for writing mapfiles. It runs in an own thread and has an + 'update' method which triggers the generator to search the filesystem for + shapefiles and meta information and update mapfiles out of these + information. A 'main' method can be invoked to update the mapfile without + an running artifact server. + + TODO: Implement method stubs. + + * src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java: + Call MapfileGenerator when writing or removing shapefiles (endOfLife). + 2010-02-15 Ingo Weinzierl <ingo.weinzierl@intevation.de> * doc/conf/products/timeseries/conf_mesh.xml,
--- a/gnv-artifacts/doc/conf/conf.xml Tue Feb 16 11:01:59 2010 +0000 +++ b/gnv-artifacts/doc/conf/conf.xml Wed Feb 17 09:40:15 2010 +0000 @@ -509,4 +509,8 @@ <driver>org.h2.Driver</driver> <sql></sql> --> </database> + + <map-generator> + <mapfile path="${artifacts.config.dir}/../mapfiles/" /> + </map-generator> </artifact-database>
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java Tue Feb 16 11:01:59 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java Wed Feb 17 09:40:15 2010 +0000 @@ -46,6 +46,7 @@ import de.intevation.gnv.state.exception.StateException; import de.intevation.gnv.utils.FileUtils; +import de.intevation.gnv.utils.MapfileGenerator; import de.intevation.gnv.utils.Pair; import de.intevation.gnv.utils.ShapeFileWriter; import de.intevation.gnv.utils.StringUtils; @@ -147,8 +148,10 @@ for (int i = 0; i < 10; ++i) { if (!dir.exists() || FileUtils.deleteRecursive(dir)) { + MapfileGenerator.getInstance().update(); return; } + try { Thread.sleep(10000L); } @@ -317,6 +320,8 @@ callContext.afterCall(CallContext.STORE); + MapfileGenerator.getInstance().update(); + return shapeFilePath; } finally {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java Wed Feb 17 09:40:15 2010 +0000 @@ -0,0 +1,79 @@ +package de.intevation.gnv.utils; + +import org.apache.log4j.Logger; + + +/** + * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) + */ +public class MapfileGenerator +extends Thread +{ + + public static final String MAPFILE_PATH = + "/artifact-database/map-generator/mapfile/@path"; + + protected static final long SLEEPTIME = 10 * 1000L; // 10 seconds + + private static Logger logger = Logger.getLogger(MapfileGenerator.class); + + private static MapfileGenerator instance; + + private boolean lock[]; + + + + private MapfileGenerator() { + lock = new boolean[1]; + } + + + public static void main(String[] args) { + // TODO Implement me + } + + + public static synchronized MapfileGenerator getInstance() { + if (instance == null) { + instance = new MapfileGenerator(); + instance.setDaemon(true); + instance.start(); + } + + return instance; + } + + + public void update() { + synchronized (lock) { + lock[0] = true; + lock.notify(); + } + } + + + public void run() { + try { + for (;;) { + synchronized (lock) { + while (!lock[0]) { + lock.wait(SLEEPTIME); + } + + lock[0] = false; + } + + logger.info("Update mapfile for MapServer."); + generate(); + } + } + catch (InterruptedException ie) { + } + } + + + private void generate() { + logger.debug("IMPLEMENT ME"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: