# HG changeset patch # User Sascha L. Teichmann # Date 1311605743 0 # Node ID 598a5e911118e91fe0d16c9a52c6896f096986b7 # Parent d830c398c8f43f82d336f005d3bdba36388a5065 Made meta data service thread safe. flys-artifacts/trunk@2403 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d830c398c8f4 -r 598a5e911118 flys-artifacts/ChangeLog --- 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 + + * 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 * doc/conf/meta-data-template.xml: '$recommended' lead to XPath diff -r d830c398c8f4 -r 598a5e911118 flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java --- 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 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 rootsToList(NodeList roots) { + protected List rootsToList() { + + NodeList roots = template.getElementsByTagNameNS( + DC_NAMESPACE_URI, "template"); List elements = new ArrayList(); @@ -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 :