01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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
41: AbstractMethodEndpointAdapter {
42:
43: protected boolean supportsInternal(MethodEndpoint methodEndpoint) {
44: Method method = methodEndpoint.getMethod();
45: return Void.TYPE.isAssignableFrom(method.getReturnType())
46: && method.getParameterTypes().length == 1
47: && MessageContext.class.isAssignableFrom(method
48: .getParameterTypes()[0]);
49: }
50:
51: protected void invokeInternal(MessageContext messageContext,
52: MethodEndpoint methodEndpoint) throws Exception {
53: methodEndpoint.invoke(new Object[] { messageContext });
54: }
55:
56: }
|