Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/BuilderPool.java @ 9232:5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
Needs to provide the ArtifactDatabase to the builder implementation.
author | gernotbelger |
---|---|
date | Fri, 06 Jul 2018 13:09:54 +0200 |
parents | 5e38e2924c07 |
children |
comparison
equal
deleted
inserted
replaced
9231:082e8e808902 | 9232:5030c46d8cb4 |
---|---|
18 import javax.xml.parsers.DocumentBuilder; | 18 import javax.xml.parsers.DocumentBuilder; |
19 import javax.xml.parsers.DocumentBuilderFactory; | 19 import javax.xml.parsers.DocumentBuilderFactory; |
20 import javax.xml.parsers.ParserConfigurationException; | 20 import javax.xml.parsers.ParserConfigurationException; |
21 | 21 |
22 import org.apache.log4j.Logger; | 22 import org.apache.log4j.Logger; |
23 | 23 import org.dive4elements.artifacts.CallContext; |
24 import org.w3c.dom.Document; | 24 import org.w3c.dom.Document; |
25 import org.w3c.dom.Node; | 25 import org.w3c.dom.Node; |
26 | 26 |
27 /** A little round robin pool of builders to mitigate | 27 /** A little round robin pool of builders to mitigate |
28 * the fact the XML DOM documents are not thread safe. | 28 * the fact the XML DOM documents are not thread safe. |
76 + "This will lead to threading issues."); | 76 + "This will lead to threading issues."); |
77 | 77 |
78 return document; | 78 return document; |
79 } | 79 } |
80 | 80 |
81 public void build( | 81 public void build( final List<Builder.NamedConnection> connections, final Node output, final Map<String, Object> parameters, final CallContext context ) throws SQLException |
82 List<Builder.NamedConnection> connections, | |
83 Node output, | |
84 Map<String, Object> parameters | |
85 ) | |
86 throws SQLException | |
87 { | 82 { |
88 Builder builder; | 83 Builder builder; |
89 synchronized (pool) { | 84 synchronized (pool) { |
90 try { | 85 try { |
91 while ((builder = pool.poll()) == null) { | 86 while ((builder = pool.poll()) == null) { |
92 pool.wait(); | 87 pool.wait(); |
93 } | 88 } |
94 } | 89 } |
95 catch (InterruptedException ie) { | 90 catch (InterruptedException ie) { |
96 log.debug("Waiting for builder interrupted. Build canceled."); | 91 log.debug("Waiting for builder interrupted. Build canceled.", ie); |
97 return; | 92 return; |
98 } | 93 } |
99 } | 94 } |
100 try { | 95 try { |
101 builder.build(connections, output, parameters); | 96 builder.build(connections, output, parameters, context); |
102 } | 97 } |
103 finally { | 98 finally { |
104 synchronized (pool) { | 99 synchronized (pool) { |
105 pool.add(builder); | 100 pool.add(builder); |
106 pool.notify(); | 101 pool.notify(); |