Spring Web Services Framework

org.springframework.ws.server.endpoint
Class AbstractDomPayloadEndpoint

java.lang.Object
  extended by org.springframework.xml.transform.TransformerObjectSupport
      extended by org.springframework.ws.server.endpoint.AbstractDomPayloadEndpoint
All Implemented Interfaces:
PayloadEndpoint

public abstract class AbstractDomPayloadEndpoint
extends TransformerObjectSupport
implements PayloadEndpoint

Abstract base class for endpoints that handle the message payload as DOM elements.

Offers the message payload as a DOM Element, and allows subclasses to create a response by returning an Element.

An AbstractDomPayloadEndpoint only accept one payload element. Multiple payload elements are not in accordance with WS-I.

Since:
1.0.0
Author:
Arjen Poutsma, Alef Arendsen
See Also:
invokeInternal(org.w3c.dom.Element,org.w3c.dom.Document)

Field Summary
 
Fields inherited from class org.springframework.xml.transform.TransformerObjectSupport
logger
 
Constructor Summary
AbstractDomPayloadEndpoint()
           
 
Method Summary
protected  DocumentBuilder createDocumentBuilder(DocumentBuilderFactory factory)
          Create a DocumentBuilder that this endpoint will use for parsing XML documents.
protected  DocumentBuilderFactory createDocumentBuilderFactory()
          Create a DocumentBuilderFactory that this endpoint will use for constructing XML documents.
protected  Element getDocumentElement(Source source, DocumentBuilder documentBuilder)
          Returns the payload element of the given source.
 Source invoke(Source request)
          Invokes the endpoint with the given request payload, and possibly returns a response.
protected abstract  Element invokeInternal(Element requestElement, Document responseDocument)
          Template method that subclasses must implement to process the request.
 void setAlwaysTransform(boolean alwaysTransform)
          Set if the request Source should always be transformed into a new DOMResult.
 void setNamespaceAware(boolean namespaceAware)
          Set whether or not the XML parser should be XML namespace aware.
 void setValidating(boolean validating)
          Set if the XML parser should validate the document.
 
Methods inherited from class org.springframework.xml.transform.TransformerObjectSupport
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDomPayloadEndpoint

public AbstractDomPayloadEndpoint()
Method Detail

setNamespaceAware

public void setNamespaceAware(boolean namespaceAware)
Set whether or not the XML parser should be XML namespace aware. Default is true.


setValidating

public void setValidating(boolean validating)
Set if the XML parser should validate the document. Default is false.


setAlwaysTransform

public void setAlwaysTransform(boolean alwaysTransform)
Set if the request Source should always be transformed into a new DOMResult.

Default is false, which is faster.


invoke

public final Source invoke(Source request)
                    throws Exception
Description copied from interface: PayloadEndpoint
Invokes the endpoint with the given request payload, and possibly returns a response.

Specified by:
invoke in interface PayloadEndpoint
Parameters:
request - the payload of the request message, may be null
Returns:
the payload of the response message, may be null to indicate no response
Throws:
Exception - if an exception occurs

createDocumentBuilder

protected DocumentBuilder createDocumentBuilder(DocumentBuilderFactory factory)
                                         throws ParserConfigurationException
Create a DocumentBuilder that this endpoint will use for parsing XML documents. Can be overridden in subclasses, adding further initialization of the builder.

Parameters:
factory - the DocumentBuilderFactory that the DocumentBuilder should be created with
Returns:
the DocumentBuilder
Throws:
ParserConfigurationException - if thrown by JAXP methods

createDocumentBuilderFactory

protected DocumentBuilderFactory createDocumentBuilderFactory()
                                                       throws ParserConfigurationException
Create a DocumentBuilderFactory that this endpoint will use for constructing XML documents. Can be overridden in subclasses, adding further initialization of the factory. The resulting DocumentBuilderFactory is cached, so this method will only be called once.

Returns:
the DocumentBuilderFactory
Throws:
ParserConfigurationException - if thrown by JAXP methods

getDocumentElement

protected Element getDocumentElement(Source source,
                                     DocumentBuilder documentBuilder)
                              throws TransformerException
Returns the payload element of the given source.

Default implementation checks whether the source is a DOMSource, and returns the node of that. In all other cases, or when alwaysTransform is true, the source is transformed into a DOMResult, which is more expensive. If the passed source is null, null is returned.

Parameters:
source - the source to return the root element of; can be null
documentBuilder - the document builder to be used for transformations
Returns:
the document element
Throws:
TransformerException - in case of errors

invokeInternal

protected abstract Element invokeInternal(Element requestElement,
                                          Document responseDocument)
                                   throws Exception
Template method that subclasses must implement to process the request.

Offers the request payload as a DOM Element, and allows subclasses to return a response Element.

The given DOM Document is to be used for constructing Nodes, by using the various create methods.

Parameters:
requestElement - the contents of the SOAP message as DOM elements
responseDocument - a DOM document to be used for constructing Nodes
Returns:
the response element. Can be null to specify no response.
Throws:
Exception

Spring Web Services Framework

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