INT-1453 added support for File-typed payloads in XPath components

This commit is contained in:
Mark Fisher
2010-09-15 14:24:12 -07:00
parent d9671c6cf1
commit 8d2b29da4d

View File

@@ -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.
@@ -16,6 +16,7 @@
package org.springframework.integration.xml;
import java.io.File;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
@@ -55,6 +56,14 @@ public class DefaultXmlPayloadConverter implements XmlPayloadConverter {
if (object instanceof Document) {
return (Document) object;
}
if (object instanceof File) {
try {
return getDocumentBuilder().parse((File) object);
}
catch (Exception e) {
throw new MessagingException("failed to parse File payload '" + object + "'", e);
}
}
if (object instanceof String) {
try {
return getDocumentBuilder().parse(new InputSource(new StringReader((String) object)));