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
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 * 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.
 */
package org.springframework.ws.server.endpoint.adapter.method;
Abstract base class for MethodArgumentResolver and MethodReturnValueHandler implementations based on javax.xml.transform.Sources.

Author(s):
Arjen Poutsma
Since:
2.0
    // MethodArgumentResolver
    public final Object resolveArgument(MessageContext messageContextMethodParameter parameterthrows Exception {
        Source requestPayload = getRequestPayload(messageContext);
        return requestPayload != null ? resolveRequestPayloadArgument(parameterrequestPayload) : null;
    }

    
Returns the request payload as Source.
    private Source getRequestPayload(MessageContext messageContext) {
        WebServiceMessage request = messageContext.getRequest();
        return request != null ? request.getPayloadSource() : null;
    }

    
Resolves the given parameter, annotated with org.springframework.ws.server.endpoint.annotation.RequestPayload, into a method argument.

Parameters:
parameter the parameter to resolve to an argument
requestPayload the request payload
Returns:
the resolved argument. May be null.
Throws:
java.lang.Exception in case of errors
    protected abstract Object resolveRequestPayloadArgument(MethodParameter parameterSource requestPayload)
            throws Exception;
    // MethodReturnValueHandler
    public final void handleReturnValue(MessageContext messageContextMethodParameter returnTypeObject returnValue)
            throws Exception {
        if (returnValue != null) {
            Source responsePayload = createResponsePayload(returnTypereturnValue);
            if (responsePayload != null) {
                WebServiceMessage response = messageContext.getResponse();
                transform(responsePayloadresponse.getPayloadResult());
            }
        }
    }

    
Creates a response payload for the given return value.

Parameters:
returnType the return type to handle
returnValue the return value to handle
Returns:
the response payload
Throws:
java.lang.Exception in case of errors
    protected abstract Source createResponsePayload(MethodParameter returnTypeObject returnValuethrows Exception;
New to GrepCode? Check out our FAQ X