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.
Subclass of MarshallingMethodEndpointAdapter that supports org.springframework.oxm.GenericMarshaller and org.springframework.oxm.GenericUnmarshaller. More specifically, this adapter is aware of the java.lang.reflect.Method.getGenericParameterTypes() and java.lang.reflect.Method.getGenericReturnType().

Prefer to use this adapter rather than the plain MarshallingMethodEndpointAdapter in combination with Java 5 marshallers, such as the org.springframework.oxm.jaxb.Jaxb2Marshaller.

as of Spring Web Services 2.0, in favor of DefaultMethodEndpointAdapter and
Arjen Poutsma

Creates a new GenericMarshallingMethodEndpointAdapter 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-WS also implement the org.springframework.oxm.Unmarshaller interface, so that you can safely use this constructor.

marshaller object used as marshaller and unmarshaller
java.lang.IllegalArgumentException when marshaller does not implement the org.springframework.oxm.Unmarshaller interface
     public GenericMarshallingMethodEndpointAdapter(Marshaller marshaller) {

Creates a new GenericMarshallingMethodEndpointAdapter with the given marshaller and unmarshaller.

marshaller the marshaller to use
unmarshaller the unmarshaller to use
     public GenericMarshallingMethodEndpointAdapter(Marshaller marshallerUnmarshaller unmarshaller) {
     protected boolean supportsInternal(MethodEndpoint methodEndpoint) {
         Method method = methodEndpoint.getMethod();
         return supportsReturnType(method) && supportsParameters(method);
     private boolean supportsReturnType(Method method) {
         if (..equals(method.getReturnType())) {
             return true;
         else {
             if (getMarshaller() instanceof GenericMarshaller) {
                 return ((GenericMarshallergetMarshaller()).supports(method.getGenericReturnType());
             else {
                 return getMarshaller().supports(method.getReturnType());
    private boolean supportsParameters(Method method) {
        if (method.getParameterTypes().length != 1) {
            return false;
        else if (getUnmarshaller() instanceof GenericUnmarshaller) {
            GenericUnmarshaller genericUnmarshaller = (GenericUnmarshallergetUnmarshaller();
            return genericUnmarshaller.supports(method.getGenericParameterTypes()[0]);
        else {
            return getUnmarshaller().supports(method.getParameterTypes()[0]);
New to GrepCode? Check out our FAQ X