diff --git a/org.springframework.integration.xml/ivy.xml b/org.springframework.integration.xml/ivy.xml
index 89c80b03a8..643bd48267 100644
--- a/org.springframework.integration.xml/ivy.xml
+++ b/org.springframework.integration.xml/ivy.xml
@@ -23,6 +23,7 @@
+
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/IntegrationXmlNamespaceHandler.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/IntegrationXmlNamespaceHandler.java
new file mode 100644
index 0000000000..068ad6a101
--- /dev/null
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/IntegrationXmlNamespaceHandler.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2002-2007 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.xml.config;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+/**
+ *
+ * @author Jonas Partner
+ *
+ */
+public class IntegrationXmlNamespaceHandler extends NamespaceHandlerSupport {
+
+ public void init() {
+ registerBeanDefinitionParser("marshalling-transformer", new XmlMarshallingTransformerParser());
+ registerBeanDefinitionParser("unmarshalling-transformer", new XmlUnmarshallingTransformerParser());
+ }
+
+}
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParser.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParser.java
new file mode 100644
index 0000000000..52f8dd2e98
--- /dev/null
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParser.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2002-2007 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.xml.config;
+
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.integration.xml.result.DomResultFactory;
+import org.springframework.integration.xml.result.StringResultFactory;
+import org.springframework.integration.xml.transformer.XmlPayloadMarshallingTransformer;
+import org.springframework.util.Assert;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author Jonas Partner
+ *
+ */
+public class XmlMarshallingTransformerParser extends AbstractSingleBeanDefinitionParser {
+
+ @Override
+ protected boolean shouldGenerateId() {
+ return false;
+ }
+
+ @Override
+ protected boolean shouldGenerateIdAsFallback() {
+ return true;
+ }
+
+ @Override
+ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+ String resourceFactory = element.getAttribute("result-factory");
+ String marshaller = element.getAttribute("marshaller");
+
+ Assert.hasText(marshaller, "A unmarshaller attribute is required");
+
+ Assert.hasText(resourceFactory, "A result-factory attribute is required");
+
+ builder.getBeanDefinition().setBeanClass(XmlPayloadMarshallingTransformer.class);
+
+ builder.getBeanDefinition().getConstructorArgumentValues().addGenericArgumentValue(
+ new RuntimeBeanReference(marshaller));
+
+ if (resourceFactory.equals("DOMResult")) {
+ builder.getBeanDefinition().getPropertyValues().addPropertyValue("resultFactory", new DomResultFactory());
+ }
+ else if (resourceFactory.equals("StringResult")) {
+ builder.getBeanDefinition().getPropertyValues()
+ .addPropertyValue("resultFactory", new StringResultFactory());
+ }
+ }
+
+}
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/XmlUnmarshallingTransformerParser.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/XmlUnmarshallingTransformerParser.java
new file mode 100644
index 0000000000..a6ed7f073f
--- /dev/null
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/XmlUnmarshallingTransformerParser.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2002-2007 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.xml.config;
+
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.integration.xml.transformer.XmlPayloadUnmarshallingTransfomer;
+import org.springframework.util.Assert;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author Jonas Partner
+ *
+ */
+public class XmlUnmarshallingTransformerParser extends AbstractSingleBeanDefinitionParser {
+
+ @Override
+ protected boolean shouldGenerateId() {
+ return false;
+ }
+
+ @Override
+ protected boolean shouldGenerateIdAsFallback() {
+ return true;
+ }
+
+ @Override
+ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+ String unmarshaller = element.getAttribute("unmarshaller");
+ Assert.hasText(unmarshaller, "A unmarshaller attribute is required");
+ builder.getBeanDefinition().setBeanClass(XmlPayloadUnmarshallingTransfomer.class);
+ builder.getBeanDefinition().getConstructorArgumentValues().addGenericArgumentValue(
+ new RuntimeBeanReference(unmarshaller));
+ }
+
+}
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/spring-integration-xml-1.0.xsd b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/spring-integration-xml-1.0.xsd
new file mode 100644
index 0000000000..35e2d215d6
--- /dev/null
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/config/spring-integration-xml-1.0.xsd
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Defines a XML marshalling transformer.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Defines a XML unmarshalling transformer.
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/result/DomResultFactory.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/result/DomResultFactory.java
index e341c688a7..ce63bddea8 100644
--- a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/result/DomResultFactory.java
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/result/DomResultFactory.java
@@ -24,7 +24,7 @@ import org.springframework.integration.message.Message;
/**
*
* @author Jonas Partner
- *
+ *
*/
public class DomResultFactory implements ResultFactory {
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/result/StringResultFactory.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/result/StringResultFactory.java
index b7f8e65cf5..dc0c21ebfa 100644
--- a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/result/StringResultFactory.java
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/result/StringResultFactory.java
@@ -24,7 +24,7 @@ import org.springframework.xml.transform.StringResult;
/**
*
* @author Jonas Partner
- *
+ *
*/
public class StringResultFactory implements ResultFactory {
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/source/DomSourceFactory.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/source/DomSourceFactory.java
new file mode 100644
index 0000000000..677d40681a
--- /dev/null
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/source/DomSourceFactory.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2002-2007 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.xml.source;
+
+import java.io.StringReader;
+
+import javax.sound.sampled.SourceDataLine;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
+import org.springframework.integration.message.Message;
+import org.springframework.integration.message.MessagingException;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+/**
+ * {@link SourceDataLine} implementation which supports creation of a
+ * {@link DOMSource} from a {@link Document} or {@link String} payload
+ *
+ * @author Jonas Partner
+ *
+ */
+public class DomSourceFactory implements SourceFactory {
+
+ private final DocumentBuilderFactory docBuilderFactory;
+
+ public DomSourceFactory() {
+ this.docBuilderFactory = DocumentBuilderFactory.newInstance();
+ }
+
+ public DomSourceFactory(DocumentBuilderFactory docBuilderFactory) {
+ this.docBuilderFactory = docBuilderFactory;
+ }
+
+ public Source getSourceForMessage(Message> message) {
+ if (Document.class.isAssignableFrom(message.getPayload().getClass())) {
+ return createDomSourceForDocument(message);
+ }
+ else if (message.getPayload() instanceof String) {
+ return createDomSourceForString(message);
+ }
+ throw new MessagingException(message, "Could not create Source for payload type "
+ + message.getPayload().getClass().getName());
+ }
+
+ protected DOMSource createDomSourceForDocument(Message> message) {
+ DOMSource source = new DOMSource(((Document) message.getPayload()).getDocumentElement());
+ return source;
+ }
+
+ protected DOMSource createDomSourceForString(Message> message) {
+ try {
+ String str = (String) message.getPayload();
+ Document doc = docBuilderFactory.newDocumentBuilder().parse(new InputSource(new StringReader(str)));
+ DOMSource source = new DOMSource(doc.getDocumentElement());
+ return source;
+ }
+ catch (Exception e) {
+ throw new MessagingException(message, "Exception creating DOMSource", e);
+ }
+ }
+
+}
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/source/SourceFactory.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/source/SourceFactory.java
index e2161db652..41110be179 100644
--- a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/source/SourceFactory.java
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/source/SourceFactory.java
@@ -23,6 +23,7 @@ import org.springframework.integration.message.Message;
/**
* Factory to create instances of {@link Source} possibly taking into account
* the contents of the passed {@link Message}
+ *
* @author Jonas Partner
*
*/
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/ResultToDocumentTransformer.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/ResultToDocumentTransformer.java
new file mode 100644
index 0000000000..cc7651ad79
--- /dev/null
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/ResultToDocumentTransformer.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2002-2007 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.xml.transformer;
+
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.dom.DOMResult;
+
+import org.springframework.integration.message.Message;
+import org.springframework.integration.message.MessagingException;
+import org.springframework.integration.transformer.MessageTransformer;
+import org.springframework.xml.transform.StringResult;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+/**
+ * Creates a {@link Document} from a {@link Result} payload
+ * @author Jonas Partner
+ *
+ */
+public class ResultToDocumentTransformer implements MessageTransformer {
+
+ // Not guaranteed to be thread safe
+ private final DocumentBuilderFactory documentBuilderFactory;
+
+ public ResultToDocumentTransformer(DocumentBuilderFactory documentBuilderFactory) {
+ this.documentBuilderFactory = documentBuilderFactory;
+ }
+
+ public ResultToDocumentTransformer() {
+ this(DocumentBuilderFactory.newInstance());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void transform(Message message) {
+ Document doc;
+ if (DOMResult.class.isAssignableFrom(message.getPayload().getClass())) {
+ doc = createDocumentFromDomResult(message, (DOMResult) message.getPayload());
+
+ }
+ else if (StringResult.class.isAssignableFrom(message.getPayload().getClass())) {
+ doc = createDocumentFromStringResult(message, (StringResult) message.getPayload());
+ }
+ else {
+ throw new MessagingException(message, "Could not create document from payload type "
+ + message.getPayload().getClass().getName());
+ }
+
+ message.setPayload(doc);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Document createDocumentFromDomResult(Message message, DOMResult domResult) {
+ return (Document) domResult.getNode();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Document createDocumentFromStringResult(Message message, StringResult stringResult) {
+ try {
+ return getDocumentBuilder().parse(new InputSource(new StringReader(stringResult.toString())));
+ }
+ catch (Exception e) {
+ throw new MessagingException(message, "Exception creating Document form StringResult payload", e);
+ }
+ }
+
+ protected synchronized DocumentBuilder getDocumentBuilder() {
+ try {
+ return documentBuilderFactory.newDocumentBuilder();
+ }
+ catch (ParserConfigurationException parseE) {
+ throw new MessagingException("Failed to create a new DocumentBuilder", parseE);
+ }
+ }
+
+}
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/SourceCreatingTransformer.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/SourceCreatingTransformer.java
new file mode 100644
index 0000000000..5d032e390c
--- /dev/null
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/SourceCreatingTransformer.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2002-2007 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.xml.transformer;
+
+import javax.xml.transform.Source;
+
+import org.springframework.integration.message.Message;
+import org.springframework.integration.transformer.MessageTransformer;
+import org.springframework.integration.xml.source.DomSourceFactory;
+import org.springframework.integration.xml.source.SourceFactory;
+
+/**
+ * Transforms the payload to a {@link Source} using a {@link SourceFactory}
+ * Default to using a {@link DomSourceFactory} if alternative is not provided
+ *
+ * @author Jonas Partner
+ *
+ */
+public class SourceCreatingTransformer implements MessageTransformer {
+
+ private final SourceFactory sourceFactory;
+
+ public SourceCreatingTransformer() {
+ sourceFactory = new DomSourceFactory();
+ }
+
+ public SourceCreatingTransformer(SourceFactory sourceFactory) {
+ this.sourceFactory = sourceFactory;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void transform(Message message) {
+ message.setPayload(sourceFactory.getSourceForMessage(message));
+ }
+
+}
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XmlPayloadMarshallingTransformer.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XmlPayloadMarshallingTransformer.java
index 1255795db1..b114781bec 100644
--- a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XmlPayloadMarshallingTransformer.java
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XmlPayloadMarshallingTransformer.java
@@ -33,6 +33,7 @@ import org.springframework.util.Assert;
* {@link Marshaller}
*
* @author Mark Fisher
+ * @author Jonas Partner
*/
public class XmlPayloadMarshallingTransformer implements MessageTransformer {
@@ -46,6 +47,7 @@ public class XmlPayloadMarshallingTransformer implements MessageTransformer {
}
public void setResultFactory(ResultFactory resultFactory) {
+ Assert.notNull(resultFactory, " the ResultFactory can not be null");
this.resultFactory = resultFactory;
}
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XmlPayloadUnmarshallingTransfomer.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XmlPayloadUnmarshallingTransfomer.java
index 073d72d745..2a6813976f 100644
--- a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XmlPayloadUnmarshallingTransfomer.java
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XmlPayloadUnmarshallingTransfomer.java
@@ -23,12 +23,15 @@ import javax.xml.transform.Source;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessagingException;
import org.springframework.integration.transformer.MessageTransformer;
+import org.springframework.integration.xml.source.DomSourceFactory;
import org.springframework.integration.xml.source.SourceFactory;
import org.springframework.oxm.Unmarshaller;
/**
* An implementation of {@link MessageTransformer} that delegates to an OXM
- * {@link Unmarshaller}
+ * {@link Unmarshaller} Expects the payload to be of type {@link Source} or to
+ * have an instance of {@link SourceFactory} that can convert to a
+ * {@link Source}
*
* @author Jonas Partner
*/
@@ -36,7 +39,7 @@ public class XmlPayloadUnmarshallingTransfomer implements MessageTransformer {
private final Unmarshaller unmarshaller;
- private SourceFactory sourceFactory;
+ private SourceFactory sourceFactory = new DomSourceFactory();
public XmlPayloadUnmarshallingTransfomer(Unmarshaller unmarshaller) {
this.unmarshaller = unmarshaller;
@@ -58,7 +61,7 @@ public class XmlPayloadUnmarshallingTransfomer implements MessageTransformer {
if (source == null) {
throw new MessagingException(message,
- "Could not transform message payload not assignable from javax.xml.transform.Source and no conversion possible");
+ "Could not transform message, payload not assignable from javax.xml.transform.Source and no conversion possible");
}
Object unmarshalled;
diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java
index 7050c37c24..8ccbd75216 100644
--- a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java
+++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java
@@ -20,18 +20,15 @@ import javax.xml.transform.Source;
import javax.xml.transform.Templates;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
-import org.w3c.dom.Document;
-
import org.springframework.core.io.Resource;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessagingException;
import org.springframework.integration.transformer.MessageTransformer;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
+import org.w3c.dom.Document;
/**
* Simple XSLT transformer implementation which returns a transformed
@@ -54,18 +51,13 @@ public class XsltPayloadTransformer implements MessageTransformer {
@SuppressWarnings("unchecked")
public void transform(Message message) {
try {
- if (Document.class.isAssignableFrom(message.getPayload().getClass())) {
- this.transformDocument(message);
- }
- else if (Source.class.isAssignableFrom(message.getPayload().getClass())) {
+ if (Source.class.isAssignableFrom(message.getPayload().getClass())) {
this.transformSource(message);
}
- else if (String.class.equals(message.getPayload().getClass())) {
- this.transformString(message);
- }
else {
- throw new MessagingException(message, "Unsupported payload type for transformation: "
- + message.getPayload().getClass().getName());
+ throw new MessagingException(message,
+ "Unsupported payload type for transformation expected javax.xml.transform.Source but got : "
+ + message.getPayload().getClass().getName());
}
}
catch (TransformerException e) {
@@ -80,19 +72,4 @@ public class XsltPayloadTransformer implements MessageTransformer {
message.setPayload(new StringSource(result.toString()));
}
- @SuppressWarnings("unchecked")
- protected void transformString(Message message) throws TransformerException {
- StringResult result = new StringResult();
- this.templates.newTransformer().transform(new StringSource((String) message.getPayload()), result);
- message.setPayload(result.toString());
- }
-
- @SuppressWarnings("unchecked")
- protected void transformDocument(Message message) throws TransformerException {
- Document doc = (Document) message.getPayload();
- DOMResult result = new DOMResult();
- this.templates.newTransformer().transform(new DOMSource(doc), result);
- message.setPayload(result.getNode());
- }
-
}
diff --git a/org.springframework.integration.xml/src/main/resources/META-INF/spring.handlers b/org.springframework.integration.xml/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000000..6cbe04a450
--- /dev/null
+++ b/org.springframework.integration.xml/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+http\://www.springframework.org/schema/integration-xml=org.springframework.integration.xml.config.IntegrationXmlNamespaceHandler
\ No newline at end of file
diff --git a/org.springframework.integration.xml/src/main/resources/META-INF/spring.schemas b/org.springframework.integration.xml/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000000..7e094c23d6
--- /dev/null
+++ b/org.springframework.integration.xml/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+http\://www.springframework.org/schema/integration/spring-integration-xml-1.0.xsd=org/springframework/integration/xml/config/spring-integration-xml-1.0.xsd
\ No newline at end of file
diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/StubMarshaller.java b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/StubMarshaller.java
new file mode 100644
index 0000000000..f6ca049357
--- /dev/null
+++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/StubMarshaller.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2002-2007 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.xml.config;
+
+import java.io.IOException;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+
+import org.springframework.oxm.Marshaller;
+import org.springframework.oxm.XmlMappingException;
+import org.springframework.xml.transform.StringSource;
+
+public class StubMarshaller implements Marshaller {
+
+ public void marshal(Object graph, Result result) throws XmlMappingException, IOException {
+ try {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ StringSource stringSource = new StringSource("" + graph.toString() + "");
+ transformer.transform(stringSource, result);
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean supports(Class clazz) {
+ return true;
+ }
+
+}
diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/StubUnmarshaller.java b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/StubUnmarshaller.java
new file mode 100644
index 0000000000..a51c728280
--- /dev/null
+++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/StubUnmarshaller.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2002-2007 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.xml.config;
+
+import java.io.IOException;
+import java.util.LinkedList;
+
+import javax.xml.transform.Source;
+
+import org.springframework.oxm.Unmarshaller;
+import org.springframework.oxm.XmlMappingException;
+
+public class StubUnmarshaller implements Unmarshaller {
+
+ public LinkedList sourcesPassed = new LinkedList();
+
+ @SuppressWarnings("unchecked")
+ public boolean supports(Class clazz) {
+ return true;
+ }
+
+ public Object unmarshal(Source source) throws XmlMappingException, IOException {
+ sourcesPassed.addFirst(source);
+ return "unmarshalled";
+ }
+
+}
diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests-context.xml b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests-context.xml
new file mode 100644
index 0000000000..1dcae38591
--- /dev/null
+++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests-context.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests.java b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests.java
new file mode 100644
index 0000000000..5ba59b5718
--- /dev/null
+++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2002-2007 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.xml.config;
+
+import static org.junit.Assert.*;
+
+import javax.xml.transform.dom.DOMResult;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.integration.message.GenericMessage;
+import org.springframework.integration.transformer.MessageTransformer;
+import org.springframework.xml.transform.StringResult;
+import org.w3c.dom.Document;
+
+/**
+ *
+ * @author Jonas Partner
+ *
+ */
+public class XmlMarshallingTransformerParserTests {
+
+ ApplicationContext appContext;
+
+ @Before
+ public void setUp(){
+ appContext = new ClassPathXmlApplicationContext("XmlMarshallingTransformerParserTests-context.xml", getClass());
+ }
+
+ @Test
+ public void testDefault() throws Exception{
+ MessageTransformer transformer = (MessageTransformer)appContext.getBean("marshallingTransfomerNoResultFactory");
+ GenericMessage