1 /* 2 * Copyright 2007 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.springframework.ws.server.endpoint.adapter; 18 19 import java.lang.reflect.Method; 20 21 import org.springframework.ws.context.MessageContext; 22 import org.springframework.ws.server.MessageDispatcher; 23 import org.springframework.ws.server.endpoint.MethodEndpoint; 24 import org.springframework.ws.soap.server.SoapMessageDispatcher; 25 26 /** 27 * Adapter that supports endpoint methods that use marshalling. Supports methods with the following signature: 28 * <pre> 29 * void handleMyMessage(MessageContext request); 30 * </pre> 31 * I.e. methods that take a single {@link MessageContext} parameter, and return <code>void</code>. The method can have 32 * any name, as long as it is mapped by an {@link org.springframework.ws.server.EndpointMapping}. 33 * <p/> 34 * This adapter is registered by default by the {@link MessageDispatcher} and {@link SoapMessageDispatcher}. 35 * 36 * @author Arjen Poutsma 37 * @since 1.0.0 38 */ 39 40 public class MessageMethodEndpointAdapter extends AbstractMethodEndpointAdapter { 41 42 protected boolean supportsInternal(MethodEndpoint methodEndpoint) { 43 Method method = methodEndpoint.getMethod(); 44 return Void.TYPE.isAssignableFrom(method.getReturnType()) && method.getParameterTypes().length == 1 && 45 MessageContext.class.isAssignableFrom(method.getParameterTypes()[0]); 46 } 47 48 protected void invokeInternal(MessageContext messageContext, MethodEndpoint methodEndpoint) throws Exception { 49 methodEndpoint.invoke(new Object[]{messageContext}); 50 } 51 52 }