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 aa498712..3ee27d90 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 @@ -77,6 +77,7 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo * interface */ protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller) { + Assert.notNull(marshaller, "marshaller must not be null"); if (!(marshaller instanceof Unmarshaller)) { throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + "interface. Please set an Unmarshaller explicitely by using the " + @@ -95,6 +96,8 @@ public abstract class AbstractMarshallingPayloadEndpoint implements MessageEndpo * @param unmarshaller the unmarshaller to use */ protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller, Unmarshaller unmarshaller) { + Assert.notNull(marshaller, "marshaller must not be null"); + Assert.notNull(unmarshaller, "unmarshaller must not be null"); this.marshaller = marshaller; this.unmarshaller = unmarshaller; } diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java b/core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java index dc6e975e..6e9be87c 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/adapter/MarshallingMethodEndpointAdapter.java @@ -61,6 +61,54 @@ public class MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdap this.unmarshaller = unmarshaller; } + /** + * Creates a new MarshallingMethodEndpointAdapter. The {@link Marshaller} and {@link Unmarshaller} + * must be injected using properties. + * + * @see #setMarshaller(org.springframework.oxm.Marshaller) + * @see #setUnmarshaller(org.springframework.oxm.Unmarshaller) + */ + public MarshallingMethodEndpointAdapter() { + } + + /** + * Creates a new MarshallingMethodEndpointAdapter 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 + */ + public MarshallingMethodEndpointAdapter(Marshaller marshaller) { + Assert.notNull(marshaller, "marshaller must not be null"); + if (!(marshaller instanceof Unmarshaller)) { + throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " + + "interface. Please set an Unmarshaller explicitely by using the " + + "MarshallingMethodEndpointAdapter(Marshaller, Unmarshaller) constructor."); + } + else { + this.marshaller = marshaller; + this.unmarshaller = (Unmarshaller) marshaller; + } + } + + /** + * Creates a new MarshallingMethodEndpointAdapter with the given marshaller and unmarshaller. + * + * @param marshaller the marshaller to use + * @param unmarshaller the unmarshaller to use + */ + public MarshallingMethodEndpointAdapter(Marshaller marshaller, Unmarshaller unmarshaller) { + Assert.notNull(marshaller, "marshaller must not be null"); + Assert.notNull(unmarshaller, "unmarshaller must not be null"); + this.marshaller = marshaller; + this.unmarshaller = unmarshaller; + } + public void afterPropertiesSet() throws Exception { Assert.notNull(marshaller, "marshaller is required"); Assert.notNull(unmarshaller, "unmarshaller is required");