Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright 2005-2010 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
  * 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.
Abstract base class for endpoints that handle the message payload as JDOM elements.

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

<pAn AbstractJDomPayloadEndpoint can accept only one payload element. Multiple payload elements are not in accordance with WS-I.

as of Spring Web Services 2.0, in favor of annotated endpoints
Arjen Poutsma
 public abstract class AbstractJDomPayloadEndpoint extends TransformerObjectSupport implements PayloadEndpoint {
     private boolean alwaysTransform = false;

Set if the request javax.xml.transform.Source should always be transformed into a new org.jdom.transform.JDOMResult.

Default is false, which is faster.

     public void setAlwaysTransform(boolean alwaysTransform) {
         this. = alwaysTransform;
     public final Source invoke(Source requestthrows Exception {
         Element requestElement = getDocumentElement(request);
         Element responseElement = invokeInternal(requestElement);
         return responseElement != null ? new JDOMSource(responseElement) : null;

Returns the payload element of the given source.

Default implementation checks whether the source is a javax.xml.transform.dom.DOMSource, and uses a org.jdom.input.DOMBuilder to create a JDOM org.jdom.Element. In all other cases, or when alwaysTransform is true, the source is transformed into a org.jdom.transform.JDOMResult, which is more expensive. If the passed source is null, null is returned.

source the source to return the root element of; can be null
the document element
javax.xml.transform.TransformerException in case of errors
     protected Element getDocumentElement(Source sourcethrows TransformerException {
         if (source == null) {
             return null;
         if (! && source instanceof DOMSource) {
             Node node = ((DOMSourcesource).getNode();
             DOMBuilder domBuilder = new DOMBuilder();
             if (node.getNodeType() == .) {
             else if (node.getNodeType() == .) {
                 Document document =;
                 return document.getRootElement();
         // we have no other option than to transform
         JDOMResult jdomResult = new JDOMResult();
         return jdomResult.getDocument().getRootElement();

Template method. Subclasses must implement this. Offers the request payload as a JDOM Element, and allows subclasses to return a response Element.

requestElement the contents of the SOAP message as JDOM element
the response element. Can be null to specify no response.
    protected abstract Element invokeInternal(Element requestElementthrows Exception;
New to GrepCode? Check out our FAQ X