diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/DomResultFactory.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/DomResultFactory.java index cf11733726..36efa6b620 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/DomResultFactory.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/DomResultFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,32 +29,34 @@ import org.springframework.integration.MessagingException; */ public class DomResultFactory implements ResultFactory { - private final DocumentBuilderFactory docBuilderFactory; + private final DocumentBuilderFactory documentBuilderFactory; - public DomResultFactory(DocumentBuilderFactory docBuilderFactory) { - this.docBuilderFactory = docBuilderFactory; + + public DomResultFactory(DocumentBuilderFactory documentBuilderFactory) { + this.documentBuilderFactory = documentBuilderFactory; } public DomResultFactory() { - this.docBuilderFactory = DocumentBuilderFactory.newInstance(); - docBuilderFactory.setNamespaceAware(true); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + this.documentBuilderFactory = factory; } + public synchronized Result createResult(Object payload) { try { return new DOMResult(getNewDocumentBuilder().newDocument()); } catch (ParserConfigurationException e) { - throw new MessagingException("Failed to create Result for payload type [" + payload.getClass().getName() - + "]"); + throw new MessagingException("failed to create Result for payload type [" + + payload.getClass().getName() + "]"); } } protected DocumentBuilder getNewDocumentBuilder() throws ParserConfigurationException { - synchronized (docBuilderFactory) { - return docBuilderFactory.newDocumentBuilder(); + synchronized (this.documentBuilderFactory) { + return this.documentBuilderFactory.newDocumentBuilder(); } - } } diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/ResultFactory.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/ResultFactory.java index 287aa90f7e..e25122f0b3 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/ResultFactory.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/ResultFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/StringResultFactory.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/StringResultFactory.java index 0b28954a98..c955e3ec8d 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/StringResultFactory.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/result/StringResultFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/router/XPathRouter.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/router/XPathRouter.java index 23bc2720bc..5833613cc1 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/router/XPathRouter.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/router/XPathRouter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.w3c.dom.DOMException; +import org.w3c.dom.Node; + import org.springframework.integration.Message; import org.springframework.integration.router.AbstractMessageRouter; import org.springframework.integration.xml.DefaultXmlPayloadConverter; @@ -27,18 +30,15 @@ import org.springframework.integration.xml.XmlPayloadConverter; import org.springframework.xml.xpath.NodeMapper; import org.springframework.xml.xpath.XPathExpression; import org.springframework.xml.xpath.XPathExpressionFactory; -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; /** - * Abstract base class for Message Routers that use - * {@link XPathExpression} evaluation to determine channel names. + * Message Router that uses {@link XPathExpression} evaluation to determine channel names. * * @author Jonas Partner * @author Oleg Zhurakousky */ public class XPathRouter extends AbstractMessageRouter { - + private volatile NodeMapper nodeMapper = new TextContentNodeMapper(); private final XPathExpression xPathExpression; @@ -50,8 +50,8 @@ public class XPathRouter extends AbstractMessageRouter { * Create a router that uses an XPath expression. The expression may * contain zero or more namespace prefixes. * - * @param expression - * @param namespaces + * @param expression the XPath expression as a String + * @param namespaces map of namespaces with prefixes as the map keys */ public XPathRouter(String expression, Map namespaces) { this.xPathExpression = XPathExpressionFactory.createXPathExpression(expression, namespaces); @@ -61,9 +61,9 @@ public class XPathRouter extends AbstractMessageRouter { * Create a router uses an XPath expression with one namespace. For example, * expression='/ns1:one/@type' prefix='ns1' namespace='www.example.org' * - * @param expression - * @param prefix - * @param namespace + * @param expression the XPath expression as a String + * @param prefix namespace prefix + * @param namespace namespace uri */ public XPathRouter(String expression, String prefix, String namespace) { Map namespaces = new HashMap(); @@ -75,7 +75,7 @@ public class XPathRouter extends AbstractMessageRouter { * Create a router that uses an XPath expression with no namespaces. * For example '/one/@type' * - * @param expression + * @param expression the XPath expression as a String */ public XPathRouter(String expression) { this.xPathExpression = XPathExpressionFactory.createXPathExpression(expression); @@ -84,7 +84,7 @@ public class XPathRouter extends AbstractMessageRouter { /** * Create a router that uses the provided XPath expression. * - * @param expression + * @param expression the XPath expression */ public XPathRouter(XPathExpression expression) { this.xPathExpression = expression; @@ -96,9 +96,7 @@ public class XPathRouter extends AbstractMessageRouter { } /** - * Converter used to convert payloads prior to XPath testing. - * - * @param converter + * Specify the Converter to use when converting payloads prior to XPath evaluation. */ public void setConverter(XmlPayloadConverter converter) { this.converter = converter; @@ -107,8 +105,8 @@ public class XPathRouter extends AbstractMessageRouter { protected XPathExpression getXPathExpression() { return this.xPathExpression; } - - public String getComponentType(){ + + public String getComponentType() { return "xml:xpath-router"; } @@ -125,6 +123,6 @@ public class XPathRouter extends AbstractMessageRouter { public Object mapNode(Node node, int nodeNum) throws DOMException { return node.getTextContent(); } - } + }