Author: davsclaus
Date: Thu Jan 5 06:06:18 2012
New Revision: 1227498
URL: http://svn.apache.org/viewvc?rev=1227498&view=rev
Log:
CAMEL-4799: Rename traceNamespaces to logNamespaces. Thanks to Raul for the
patch.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java
camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java
camel/trunk/components/camel-saxon/src/test/resources/org/apache/camel/language/xpath/XPathLanguageTest.xml
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java?rev=1227498&r1=1227497&r2=1227498&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java
Thu Jan 5 06:06:18 2012
@@ -89,7 +89,7 @@ public class XPathBuilder implements Exp
private static XPathFactory defaultXPathFactory;
private final Queue<XPathExpression> pool = new
ConcurrentLinkedQueue<XPathExpression>();
- private final Queue<XPathExpression> poolTraceNamespaces = new
ConcurrentLinkedQueue<XPathExpression>();
+ private final Queue<XPathExpression> poolLogNamespaces = new
ConcurrentLinkedQueue<XPathExpression>();
private final String text;
private final ThreadLocal<MessageVariableResolver> variableResolver = new
ThreadLocal<MessageVariableResolver>();
private final ThreadLocal<Exchange> exchange = new ThreadLocal<Exchange>();
@@ -103,7 +103,7 @@ public class XPathBuilder implements Exp
private QName resultQName = XPathConstants.NODESET;
private String objectModelUri;
private DefaultNamespaceContext namespaceContext;
- private boolean traceNamespaces;
+ private boolean logNamespaces;
private XPathFunctionResolver functionResolver;
private XPathFunction bodyFunction;
private XPathFunction headerFunction;
@@ -397,8 +397,8 @@ public class XPathBuilder implements Exp
*
* @return the current builder.
*/
- public XPathBuilder traceNamespaces() {
- setTraceNamespaces(true);
+ public XPathBuilder logNamespaces() {
+ setLogNamespaces(true);
return this;
}
@@ -626,12 +626,12 @@ public class XPathBuilder implements Exp
}
}
- public void setTraceNamespaces(boolean traceNamespaces) {
- this.traceNamespaces = traceNamespaces;
+ public void setLogNamespaces(boolean logNamespaces) {
+ this.logNamespaces = logNamespaces;
}
- public boolean isTraceNamespaces() {
- return traceNamespaces;
+ public boolean isLogNamespaces() {
+ return logNamespaces;
}
public String getObjectModelUri() {
@@ -681,8 +681,8 @@ public class XPathBuilder implements Exp
LOG.trace("Acquired XPathExpression from pool");
}
try {
- if (traceNamespaces && LOG.isTraceEnabled()) {
- traceNamespaces(exchange);
+ if (logNamespaces && LOG.isInfoEnabled()) {
+ logNamespaces(exchange);
}
return doInEvaluateAs(xpathExpression, exchange, resultQName);
} finally {
@@ -692,13 +692,13 @@ public class XPathBuilder implements Exp
}
}
- private void traceNamespaces(Exchange exchange) {
+ private void logNamespaces(Exchange exchange) {
InputStream is = null;
NodeList answer = null;
XPathExpression xpathExpression = null;
try {
- xpathExpression = poolTraceNamespaces.poll();
+ xpathExpression = poolLogNamespaces.poll();
if (xpathExpression == null) {
xpathExpression = createTraceNamespaceExpression();
}
@@ -723,11 +723,11 @@ public class XPathBuilder implements Exp
answer = (NodeList) xpathExpression.evaluate(document,
XPathConstants.NODESET);
}
} catch (Exception e) {
- LOG.trace("Unable to trace discovered namespaces in XPath
expression", e);
+ LOG.warn("Unable to trace discovered namespaces in XPath
expression", e);
} finally {
// IOHelper can handle if is is null
IOHelper.close(is);
- poolTraceNamespaces.add(xpathExpression);
+ poolLogNamespaces.add(xpathExpression);
}
if (answer != null) {
@@ -756,7 +756,7 @@ public class XPathBuilder implements Exp
map.get(prefix).add(namespaces.item(i).getNodeValue());
}
- LOG.trace("Namespaces discovered in message: {}.", map);
+ LOG.info("Namespaces discovered in message: {}.", map);
}
protected Object doInEvaluateAs(XPathExpression xpathExpression, Exchange
exchange, QName resultQName) {
@@ -817,8 +817,10 @@ public class XPathBuilder implements Exp
// XPathFactory is not thread safe
XPath xPath = getXPathFactory().newXPath();
- if (LOG.isTraceEnabled()) {
+ if (!logNamespaces && LOG.isTraceEnabled()) {
LOG.trace("Creating new XPath expression in pool. Namespaces on
XPath expression: {}", getNamespaceContext().toString());
+ } else if (logNamespaces && LOG.isInfoEnabled()) {
+ LOG.info("Creating new XPath expression in pool. Namespaces on
XPath expression: {}", getNamespaceContext().toString());
}
xPath.setNamespaceContext(getNamespaceContext());
xPath.setXPathVariableResolver(getVariableResolver());
@@ -981,7 +983,7 @@ public class XPathBuilder implements Exp
public void stop() throws Exception {
pool.clear();
- poolTraceNamespaces.clear();
+ poolLogNamespaces.clear();
}
protected synchronized void initDefaultXPathFactory() throws
XPathFactoryConfigurationException {
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java?rev=1227498&r1=1227497&r2=1227498&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java
Thu Jan 5 06:06:18 2012
@@ -43,8 +43,8 @@ public class XPathExpression extends Nam
private String factoryRef;
@XmlAttribute(name = "objectModel")
private String objectModel;
- @XmlAttribute(name = "traceNamespaces")
- private Boolean traceNamespaces;
+ @XmlAttribute(name = "logNamespaces")
+ private Boolean logNamespaces;
@XmlTransient
private Class<?> resultType;
@@ -110,16 +110,16 @@ public class XPathExpression extends Nam
return objectModel;
}
- public void setTraceNamespaces(Boolean traceNamespaces) {
- this.traceNamespaces = traceNamespaces;
+ public void setLogNamespaces(Boolean logNamespaces) {
+ this.logNamespaces = logNamespaces;
}
- public Boolean getTraceNamespaces() {
- return traceNamespaces;
+ public Boolean getLogNamespaces() {
+ return logNamespaces;
}
- public boolean isTraceNamespaces() {
- return traceNamespaces != null && traceNamespaces;
+ public boolean isLogNamespaces() {
+ return logNamespaces != null && logNamespaces;
}
@Override
@@ -155,8 +155,8 @@ public class XPathExpression extends Nam
if (objectModel != null) {
setProperty(expression, "objectModelUri", objectModel);
}
- if (isTraceNamespaces()) {
- ObjectHelper.cast(XPathBuilder.class,
expression).setTraceNamespaces(true);
+ if (isLogNamespaces()) {
+ ObjectHelper.cast(XPathBuilder.class,
expression).setLogNamespaces(true);
}
// moved the super configuration to the bottom so that the namespace
init picks up the newly set XPath Factory
super.configureExpression(camelContext, expression);
@@ -177,8 +177,8 @@ public class XPathExpression extends Nam
if (objectModel != null) {
setProperty(predicate, "objectModelUri", objectModel);
}
- if (isTraceNamespaces()) {
- ObjectHelper.cast(XPathBuilder.class,
predicate).setTraceNamespaces(true);
+ if (isLogNamespaces()) {
+ ObjectHelper.cast(XPathBuilder.class,
predicate).setLogNamespaces(true);
}
// moved the super configuration to the bottom so that the namespace
init picks up the newly set XPath Factory
super.configurePredicate(camelContext, predicate);
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java?rev=1227498&r1=1227497&r2=1227498&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java
Thu Jan 5 06:06:18 2012
@@ -57,12 +57,12 @@ public class XPathTransformTest extends
assertEquals("<root><firstname>Servicemix</firstname><lastname>Camel</lastname></root>",
out);
}
- public void testXPathNamespaceTracingEnabledJavaDSL() throws Exception {
+ public void testXPathNamespaceLoggingEnabledJavaDSL() throws Exception {
Logger l = createNiceMock(Logger.class);
- expect(l.isTraceEnabled()).andReturn(true).anyTimes();
+ expect(l.isInfoEnabled()).andReturn(true).anyTimes();
- l.trace(contains("Namespaces discovered in message"), anyObject());
+ l.info(contains("Namespaces discovered in message"), anyObject());
expectLastCall().times(1);
replay(l);
@@ -79,19 +79,19 @@ public class XPathTransformTest extends
logField.set(null, l);
- NodeList list = XPathBuilder.xpath("//*",
NodeList.class).traceNamespaces().evaluate(context, doc, NodeList.class);
+ NodeList list = XPathBuilder.xpath("//*",
NodeList.class).logNamespaces().evaluate(context, doc, NodeList.class);
assertNotNull(list);
verify(l);
}
- public void testXPathNamespaceTracingDisabledJavaDSL() throws Exception {
+ public void testXPathNamespaceLoggingDisabledJavaDSL() throws Exception {
Logger l = createNiceMock(Logger.class);
- expect(l.isTraceEnabled()).andReturn(true).anyTimes();
+ expect(l.isInfoEnabled()).andReturn(true).anyTimes();
Capture<String> captures = new Capture<String>(CaptureType.ALL);
- l.trace(capture(captures), anyObject());
+ l.info(capture(captures), anyObject());
expectLastCall().anyTimes();
replay(l);
@@ -116,7 +116,7 @@ public class XPathTransformTest extends
for (String c : captures.getValues()) {
if (c.contains("Namespaces discovered in message")) {
- throw new AssertionError("Did not expect LOG.trace with
'Namespaces discovered in message'");
+ throw new AssertionError("Did not expect LOG.info with
'Namespaces discovered in message'");
}
}
}
Modified:
camel/trunk/components/camel-saxon/src/test/resources/org/apache/camel/language/xpath/XPathLanguageTest.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-saxon/src/test/resources/org/apache/camel/language/xpath/XPathLanguageTest.xml?rev=1227498&r1=1227497&r2=1227498&view=diff
==============================================================================
---
camel/trunk/components/camel-saxon/src/test/resources/org/apache/camel/language/xpath/XPathLanguageTest.xml
(original)
+++
camel/trunk/components/camel-saxon/src/test/resources/org/apache/camel/language/xpath/XPathLanguageTest.xml
Thu Jan 5 06:06:18 2012
@@ -33,7 +33,7 @@
<route>
<from uri="seda:testSaxonWithFlag"/>
<setBody>
- <xpath saxon="true" resultType="java.lang.String"
traceNamespaces="true">tokenize(a, '\|')</xpath>
+ <xpath saxon="true" resultType="java.lang.String"
logNamespaces="true">tokenize(a, '\|')</xpath>
</setBody>
<log message="Test Saxon with flag: ${body}"/>
<to uri="mock:testSaxonWithFlagResult"/>
@@ -42,7 +42,7 @@
<route>
<from uri="seda:testSaxonWithFactory"/>
<setBody>
- <xpath factoryRef="saxonFactory" resultType="java.lang.String"
traceNamespaces="true">tokenize(a, '\|')</xpath>
+ <xpath factoryRef="saxonFactory" resultType="java.lang.String"
logNamespaces="true">tokenize(a, '\|')</xpath>
</setBody>
<log message="Test Saxon with factory: ${body}"/>
<to uri="mock:testSaxonWithFactoryResult"/>