Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/MapHelper.java @ 5779:ebec12def170
Datacage: Add a pool of builders to make it multi threadable.
XML DOM is not thread safe. Therefore the old implementation only allowed one thread
to use the builder at a time. As the complexity of the configuration
has increased over time this has become a bottleneck of the whole application
because it took quiet some time to build a result. Furthermore the builder code path
is visited very frequent. So many concurrent requests were piled up
resulting in long waits for the users.
To mitigate this problem a round robin pool of builders is used now.
Each of the pooled builders has an independent copy of the XML template
and can be run in parallel.
The number of builders is determined by the system property
'flys.datacage.pool.size'. It defaults to 4.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 21 Apr 2013 12:48:09 +0200 |
parents | e3bd1f412421 |
children |
rev | line source |
---|---|
1376
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Document; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.common.utils.XMLUtils; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.flys.client.shared.model.MapConfig; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 public class MapHelper { |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 private static final Logger logger = Logger.getLogger(MapHelper.class); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 public static final String XPATH_SRID = |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 "/art:floodmap/art:srid/text()"; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public static final String XPATH_MAX_EXTENT = |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 "/art:floodmap/art:maxExtent/text()"; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 public static final String XPATH_INITIAL_EXTENT = |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 "/art:floodmap/art:initialExtent/text()"; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 private MapHelper() { |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 } |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 public static MapConfig parseConfig(Document raw) { |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 logger.debug("MapHelper.parseConfig"); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1376
diff
changeset
|
35 if (logger.isDebugEnabled()) { |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1376
diff
changeset
|
36 logger.debug(XMLUtils.toString(raw)); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1376
diff
changeset
|
37 } |
1376
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 MapConfig config = new MapConfig(); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 setSrid(config, raw); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 setMaxExtent(config, raw); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 setInitialExtent(config, raw); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 return config; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 } |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 protected static void setSrid(MapConfig config, Document raw) { |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 String srid = (String) XMLUtils.xpathString( |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 raw, |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 XPATH_SRID, |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 ArtifactNamespaceContext.INSTANCE); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 logger.debug("Found srid: '" + srid + "'"); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 if (srid != null && srid.length() > 0) { |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 logger.debug("Set srid: '" + srid + "'"); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 config.setSrid(srid); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 } |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 } |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 protected static void setMaxExtent(MapConfig config, Document raw) { |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 String maxExtent = (String) XMLUtils.xpathString( |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 raw, |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 XPATH_MAX_EXTENT, |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 ArtifactNamespaceContext.INSTANCE); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 logger.debug("Found max extent: '" + maxExtent + "'"); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 if (maxExtent != null && maxExtent.length() > 0) { |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 logger.debug("Set max extent: '" + maxExtent + "'"); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 config.setMaxExtent(maxExtent); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 } |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 } |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 protected static void setInitialExtent(MapConfig config, Document raw) { |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 String initialExtent = (String) XMLUtils.xpathString( |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 raw, |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 XPATH_INITIAL_EXTENT, |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 ArtifactNamespaceContext.INSTANCE); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 if (initialExtent != null && initialExtent.length() > 0) { |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 logger.debug("Set initial extent: '" + initialExtent + "'"); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 config.setInitialExtent(initialExtent); |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 } |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 } |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 } |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |