changeset 977:598a5e911118

Made meta data service thread safe. flys-artifacts/trunk@2403 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 25 Jul 2011 14:55:43 +0000
parents d830c398c8f4
children 5e40fe173a53
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java
diffstat 2 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Jul 25 14:12:14 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Jul 25 14:55:43 2011 +0000
@@ -1,3 +1,8 @@
+2011-07-25  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java:
+	  Argh! Usage the DOM was not thread safe (discovered with ab).
+
 2011-07-25  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* doc/conf/meta-data-template.xml: '$recommended' lead to XPath
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java	Mon Jul 25 14:12:14 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java	Mon Jul 25 14:55:43 2011 +0000
@@ -66,10 +66,12 @@
             owner           = getOwnerDocument(output);
         }
 
-        public void build(List<Node> elements) throws SQLException {
+        public void build() throws SQLException {
             try {
-                for (Node current: elements) {
-                    build(output, current);
+                synchronized (template) {
+                    for (Node current: rootsToList()) {
+                        build(output, current);
+                    }
                 }
             }
             finally {
@@ -421,7 +423,10 @@
         }
     }
 
-    protected static List<Node> rootsToList(NodeList roots) {
+    protected List<Node> rootsToList() {
+
+        NodeList roots = template.getElementsByTagNameNS(
+            DC_NAMESPACE_URI, "template");
 
         List<Node> elements = new ArrayList<Node>();
 
@@ -458,10 +463,7 @@
     {
         BuildHelper helper = new BuildHelper(output, connection, parameters);
 
-        NodeList roots = template.getElementsByTagNameNS(
-            DC_NAMESPACE_URI, "template");
-
-        helper.build(rootsToList(roots));
+        helper.build();
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org