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;
 
Implementation of MethodArgumentResolver and MethodReturnValueHandler that uses org.springframework.oxm.Marshaller and org.springframework.oxm.Unmarshaller to support marshalled objects.

Author(s):
Arjen Poutsma
Since:
2.0
 
 
     private Marshaller marshaller;
 
     private Unmarshaller unmarshaller;

    
 
     }

    
Creates a new MarshallingPayloadMethodProcessor with the given marshaller. If the given org.springframework.oxm.Marshaller also implements the org.springframework.oxm.Unmarshaller interface, it is used for both marshalling and unmarshalling. Otherwise, an exception is thrown.

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

Parameters:
marshaller object used as marshaller and unmarshaller
Throws:
java.lang.IllegalArgumentException when marshaller does not implement the org.springframework.oxm.Unmarshaller interface
 
     public MarshallingPayloadMethodProcessor(Marshaller marshaller) {
         Assert.notNull(marshaller"marshaller must not be null");
         Assert.isInstanceOf(Unmarshaller.classmarshaller);
         setMarshaller(marshaller);
         setUnmarshaller((Unmarshallermarshaller);
     }

    
Creates a new MarshallingPayloadMethodProcessor with the given marshaller and unmarshaller.

Parameters:
marshaller the marshaller to use
unmarshaller the unmarshaller to use
 
     public MarshallingPayloadMethodProcessor(Marshaller marshallerUnmarshaller unmarshaller) {
         Assert.notNull(marshaller"marshaller must not be null");
         Assert.notNull(unmarshaller"unmarshaller must not be null");
         setMarshaller(marshaller);
         setUnmarshaller(unmarshaller);
     }

    
Returns the marshaller used for transforming objects into XML.
 
     public Marshaller getMarshaller() {
         return ;
     }

    
Sets the marshaller used for transforming objects into XML.
 
     public void setMarshaller(Marshaller marshaller) {
         this. = marshaller;
     }

    
Returns the unmarshaller used for transforming XML into objects.
 
    public Unmarshaller getUnmarshaller() {
        return ;
    }

    
Sets the unmarshaller used for transforming XML into objects.
    public void setUnmarshaller(Unmarshaller unmarshaller) {
        this. = unmarshaller;
    }
    @Override
    protected boolean supportsRequestPayloadParameter(MethodParameter parameter) {
        Unmarshaller unmarshaller = getUnmarshaller();
        if (unmarshaller == null) {
            return false;
        }
        else if (unmarshaller instanceof GenericUnmarshaller) {
            return ((GenericUnmarshallerunmarshaller).supports(parameter.getGenericParameterType());
        }
        else {
            return unmarshaller.supports(parameter.getParameterType());
        }
    }
    public Object resolveArgument(MessageContext messageContextMethodParameter parameterthrows Exception {
        Unmarshaller unmarshaller = getUnmarshaller();
        Assert.state(unmarshaller != null"unmarshaller must not be null");
        WebServiceMessage request = messageContext.getRequest();
        Object argument = MarshallingUtils.unmarshal(unmarshallerrequest);
        if (.isDebugEnabled()) {
            .debug("Unmarshalled payload request to [" + argument + "]");
        }
        return argument;
    }
    @Override
    protected boolean supportsResponsePayloadReturnType(MethodParameter returnType) {
        Marshaller marshaller = getMarshaller();
        if (marshaller == null) {
            return false;
        }
        else if (marshaller instanceof GenericMarshaller) {
            GenericMarshaller genericMarshaller = (GenericMarshallermarshaller;
            return genericMarshaller.supports(returnType.getGenericParameterType());
        }
        else {
            return marshaller.supports(returnType.getParameterType());
        }
    }
    public void handleReturnValue(MessageContext messageContextMethodParameter returnTypeObject returnValue)
            throws Exception {
        Marshaller marshaller = getMarshaller();
        Assert.state(marshaller != null"marshaller must not be null");
        if (.isDebugEnabled()) {
            .debug("Marshalling [" + returnValue + "] to response payload");
        }
        WebServiceMessage response = messageContext.getResponse();
        MarshallingUtils.marshal(marshallerreturnValueresponse);
    }
New to GrepCode? Check out our FAQ X