Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/StyleHelper.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 | f53e2e877aa4 |
children |
rev | line source |
---|---|
2909
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
3384
a6b7f0585761
Merge point/line label styles
Christian Lins <christian.lins@intevation.de>
parents:
2909
diff
changeset
|
3 import de.intevation.flys.client.shared.model.Style; |
a6b7f0585761
Merge point/line label styles
Christian Lins <christian.lins@intevation.de>
parents:
2909
diff
changeset
|
4 import de.intevation.flys.client.shared.model.StyleSetting; |
a6b7f0585761
Merge point/line label styles
Christian Lins <christian.lins@intevation.de>
parents:
2909
diff
changeset
|
5 |
2909
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import org.w3c.dom.Element; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.NodeList; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 public class StyleHelper { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 public static Style getStyle (Element element) { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 if (!element.getTagName().equals("theme")) { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 return null; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 NodeList list = element.getElementsByTagName("field"); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 Style style = new Style(); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 style.setName (element.getAttribute("name")); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 style.setFacet (element.getAttribute("facet")); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 try { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 int ndx = Integer.parseInt(element.getAttribute("index")); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 style.setIndex (ndx); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 catch(NumberFormatException nfe) { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 return null; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 for(int i = 0; i < list.getLength(); i++) { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 Element e = (Element) list.item(i); |
4665
f53e2e877aa4
Read and use the hidden hint correctly.
Raimund Renkert <rrenkert@intevation.de>
parents:
3384
diff
changeset
|
33 String hints = e.getAttribute("hints"); |
2909
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 StyleSetting set = new StyleSetting ( |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 e.getAttribute("name"), |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 e.getAttribute("default"), |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 e.getAttribute("display"), |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 e.getAttribute("hints"), |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 e.getAttribute("type"), |
4665
f53e2e877aa4
Read and use the hidden hint correctly.
Raimund Renkert <rrenkert@intevation.de>
parents:
3384
diff
changeset
|
41 (hints != null && hints.contains("hidden") ? true : false) |
2909
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 ); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 style.appendStyleSetting(set); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 return style; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |