Spring Web Services Framework

org.springframework.ws.server.endpoint
Class AbstractMarshallingPayloadEndpoint

java.lang.Object
  extended by org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint
All Implemented Interfaces:
InitializingBean, MessageEndpoint
Direct Known Subclasses:
AbstractValidatingMarshallingPayloadEndpoint

public abstract class AbstractMarshallingPayloadEndpoint
extends Object
implements MessageEndpoint, InitializingBean

Endpoint that unmarshals the request payload, and marshals the response object. This endpoint needs a Marshaller and Unmarshaller, both of which can be set using properties. An abstract template method is invoked using the request object as a parameter, and allows for a response object to be returned.

Since:
1.0.0
Author:
Arjen Poutsma
See Also:
setMarshaller(org.springframework.oxm.Marshaller), Marshaller, setUnmarshaller(org.springframework.oxm.Unmarshaller), Unmarshaller, invokeInternal(Object)

Field Summary
protected  Log logger
          Logger available to subclasses.
 
Constructor Summary
protected AbstractMarshallingPayloadEndpoint()
          Creates a new AbstractMarshallingPayloadEndpoint.
protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller)
          Creates a new AbstractMarshallingPayloadEndpoint with the given marshaller.
protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller, Unmarshaller unmarshaller)
          Creates a new AbstractMarshallingPayloadEndpoint with the given marshaller and unmarshaller.
 
Method Summary
 void afterMarshallerSet()
          Deprecated. as of Spring Web Services 1.5: afterPropertiesSet() is no longer final, so this can safely be overriden in subclasses
 void afterPropertiesSet()
           
 Marshaller getMarshaller()
          Returns the marshaller used for transforming objects into XML.
 Unmarshaller getUnmarshaller()
          Returns the unmarshaller used for transforming XML into objects.
 void invoke(MessageContext messageContext)
          Invokes an operation.
protected abstract  Object invokeInternal(Object requestObject)
          Template method that subclasses must implement to process a request.
protected  void onMarshalResponse(MessageContext messageContext, Object requestObject, Object responseObject)
          Callback for post-processing in terms of marshalling.
protected  boolean onUnmarshalRequest(MessageContext messageContext, Object requestObject)
          Callback for post-processing in terms of unmarshalling.
 void setMarshaller(Marshaller marshaller)
          Sets the marshaller used for transforming objects into XML.
 void setUnmarshaller(Unmarshaller unmarshaller)
          Sets the unmarshaller used for transforming XML into objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses.

Constructor Detail

AbstractMarshallingPayloadEndpoint

protected AbstractMarshallingPayloadEndpoint()
Creates a new AbstractMarshallingPayloadEndpoint. The Marshaller and Unmarshaller must be injected using properties.

See Also:
setMarshaller(org.springframework.oxm.Marshaller), setUnmarshaller(org.springframework.oxm.Unmarshaller)

AbstractMarshallingPayloadEndpoint

protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller)
Creates a new AbstractMarshallingPayloadEndpoint with the given marshaller. The given Marshaller should also implements the Unmarshaller, since it is used for both marshalling and unmarshalling. If it is not, an exception is thrown.

Note that all Marshaller implementations in Spring-WS also implement the Unmarshaller interface, so that you can safely use this constructor.

Parameters:
marshaller - object used as marshaller and unmarshaller
Throws:
IllegalArgumentException - when marshaller does not implement the Unmarshaller interface
See Also:
AbstractMarshallingPayloadEndpoint(Marshaller,Unmarshaller)

AbstractMarshallingPayloadEndpoint

protected AbstractMarshallingPayloadEndpoint(Marshaller marshaller,
                                             Unmarshaller unmarshaller)
Creates a new AbstractMarshallingPayloadEndpoint with the given marshaller and unmarshaller.

Parameters:
marshaller - the marshaller to use
unmarshaller - the unmarshaller to use
Method Detail

getMarshaller

public Marshaller getMarshaller()
Returns the marshaller used for transforming objects into XML.


setMarshaller

public final void setMarshaller(Marshaller marshaller)
Sets the marshaller used for transforming objects into XML.


getUnmarshaller

public Unmarshaller getUnmarshaller()
Returns the unmarshaller used for transforming XML into objects.


setUnmarshaller

public final void setUnmarshaller(Unmarshaller unmarshaller)
Sets the unmarshaller used for transforming XML into objects.


afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

invoke

public final void invoke(MessageContext messageContext)
                  throws Exception
Description copied from interface: MessageEndpoint
Invokes an operation.

The given messageContext can be used to create a response.

Specified by:
invoke in interface MessageEndpoint
Parameters:
messageContext - the message context
Throws:
Exception - if an exception occurs

onUnmarshalRequest

protected boolean onUnmarshalRequest(MessageContext messageContext,
                                     Object requestObject)
                              throws Exception
Callback for post-processing in terms of unmarshalling. Called on each message request, after standard unmarshalling.

Default implementation returns true.

Parameters:
messageContext - the message context
requestObject - the object unmarshalled from the request
Returns:
true to continue and call invokeInternal(Object); false otherwise
Throws:
Exception

onMarshalResponse

protected void onMarshalResponse(MessageContext messageContext,
                                 Object requestObject,
                                 Object responseObject)
Callback for post-processing in terms of marshalling. Called on each message request, after standard marshalling of the response. Only invoked when invokeInternal(Object) returns an object.

Default implementation is empty.

Parameters:
messageContext - the message context
requestObject - the object unmarshalled from the request
responseObject - the object marshalled to the MessageContext.getResponse() request}

afterMarshallerSet

public void afterMarshallerSet()
                        throws Exception
Deprecated. as of Spring Web Services 1.5: afterPropertiesSet() is no longer final, so this can safely be overriden in subclasses

Template method that gets called after the marshaller and unmarshaller have been set.

The default implementation does nothing.

Throws:
Exception

invokeInternal

protected abstract Object invokeInternal(Object requestObject)
                                  throws Exception
Template method that subclasses must implement to process a request.

The unmarshaled request object is passed as a parameter, and the returned object is marshalled to a response. If no response is required, return null.

Parameters:
requestObject - the unnmarshalled message payload as an object
Returns:
the object to be marshalled as response, or null if a response is not required
Throws:
Exception

Spring Web Services Framework

Copyright © 2005-2010 The Spring Web Services Framework. All Rights Reserved.