From 0f12f7083588098f647cfd4a303160a25b778ebf Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 15 May 2007 22:34:32 +0000 Subject: [PATCH] Added marshaller constructor. --- .../AbstractMarshallingPayloadEndpoint.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java b/core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java index 53bc0812..aa498712 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/AbstractMarshallingPayloadEndpoint.java @@ -64,6 +64,30 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo protected AbstractMarshallingPayloadEndpoint() { } + /** + * Creates a new AbstractMarshallingPayloadEndpoint with the given marshaller. If the given {@link + * Marshaller} also implements the {@link Unmarshaller} interface, it is used for both marshalling and + * unmarshalling. Otherwise, an exception is thrown. + *

+ * Note that all {@link Marshaller} implementations in Spring-WS also implement the {@link Unmarshaller} interface, + * so that you can safely use this constructor. + * + * @param marshaller object used as marshaller and unmarshaller + * @throws IllegalArgumentException when marshaller does not implement the {@link Unmarshaller} + * interface + */ + protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller) { + if (!(marshaller instanceof Unmarshaller)) { + throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + + "interface. Please set an Unmarshaller explicitely by using the " + + "AbstractMarshallingPayloadEndpoint(Marshaller, Unmarshaller) constructor."); + } + else { + this.marshaller = marshaller; + this.unmarshaller = (Unmarshaller) marshaller; + } + } + /** * Creates a new AbstractMarshallingPayloadEndpoint with the given marshaller and unmarshaller. *