Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java @ 5442:9575264f801d
Only create one FunctionResolver per BuildHelper. Creatin new ones over and over again is excessive.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Tue, 26 Mar 2013 21:55:23 +0100 |
parents | df32d7518f55 |
children | 3d7e552cc396 |
comparison
equal
deleted
inserted
replaced
5441:7c1dd9c3f6bd | 5442:9575264f801d |
---|---|
92 protected StackFrames frames; | 92 protected StackFrames frames; |
93 protected List<NamedConnection> connections; | 93 protected List<NamedConnection> connections; |
94 protected Map<String, CompiledStatement.Instance> statements; | 94 protected Map<String, CompiledStatement.Instance> statements; |
95 protected Deque<Pair<NamedConnection, ResultData>> connectionsStack; | 95 protected Deque<Pair<NamedConnection, ResultData>> connectionsStack; |
96 protected Deque<NodeList> macroBodies; | 96 protected Deque<NodeList> macroBodies; |
97 protected FunctionResolver functionResolver; | |
97 | 98 |
98 public BuildHelper( | 99 public BuildHelper( |
99 Node output, | 100 Node output, |
100 List<NamedConnection> connections, | 101 List<NamedConnection> connections, |
101 Map<String, Object> parameters | 102 Map<String, Object> parameters |
111 frames = new StackFrames(parameters); | 112 frames = new StackFrames(parameters); |
112 owner = getOwnerDocument(output); | 113 owner = getOwnerDocument(output); |
113 statements = | 114 statements = |
114 new HashMap<String, CompiledStatement.Instance>(); | 115 new HashMap<String, CompiledStatement.Instance>(); |
115 macroBodies = new ArrayDeque<NodeList>(); | 116 macroBodies = new ArrayDeque<NodeList>(); |
117 functionResolver = new FunctionResolver(this); | |
116 } | 118 } |
117 | 119 |
118 public void build() throws SQLException { | 120 public void build() throws SQLException { |
119 try { | 121 try { |
120 synchronized (template) { | 122 synchronized (template) { |
545 } | 547 } |
546 | 548 |
547 try { | 549 try { |
548 XPath xpath = XPATH_FACTORY.newXPath(); | 550 XPath xpath = XPATH_FACTORY.newXPath(); |
549 xpath.setXPathVariableResolver(frames); | 551 xpath.setXPathVariableResolver(frames); |
550 xpath.setXPathFunctionResolver(new FunctionResolver(this)); | 552 xpath.setXPathFunctionResolver(functionResolver); |
551 return xpath.evaluate(expr, EVAL_DOCUMENT, returnType); | 553 return xpath.evaluate(expr, EVAL_DOCUMENT, returnType); |
552 } | 554 } |
553 catch (XPathExpressionException xpee) { | 555 catch (XPathExpressionException xpee) { |
554 log.error("expression: " + expr, xpee); | 556 log.error("expression: " + expr, xpee); |
555 } | 557 } |