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 org.apache.commons.logging.Log;
20: import org.apache.commons.logging.LogFactory;
21: import org.springframework.ws.context.MessageContext;
22: import org.springframework.ws.server.EndpointAdapter;
23: import org.springframework.ws.server.endpoint.MethodEndpoint;
24: import org.springframework.xml.transform.TransformerObjectSupport;
25:
26: /**
27: * Abstract base class for {@link EndpointAdapter} implementations that support {@link MethodEndpoint}s. Contains
28: * template methods for handling these method endpoints.
29: *
30: * @author Arjen Poutsma
31: * @since 1.0.0
32: */
33: public abstract class AbstractMethodEndpointAdapter extends
34: TransformerObjectSupport implements EndpointAdapter {
35:
36: /** Logger available to subclasses. */
37: protected final Log logger = LogFactory.getLog(getClass());
38:
39: /**
40: * Delegates to {@link #supportsInternal(org.springframework.ws.server.endpoint.MethodEndpoint)}.
41: *
42: * @param endpoint endpoint object to check
43: * @return whether or not this adapter can adapt the given endpoint
44: */
45: public final boolean supports(Object endpoint) {
46: return endpoint instanceof MethodEndpoint
47: && supportsInternal((MethodEndpoint) endpoint);
48: }
49:
50: /**
51: * Delegates to {@link #invokeInternal(org.springframework.ws.context.MessageContext,MethodEndpoint)}.
52: *
53: * @param messageContext the current message context
54: * @param endpoint the endpoint to use. This object must have previously been passed to the
55: * <code>supportsInternal</code> method of this interface, which must have returned
56: * <code>true</code>
57: * @throws Exception in case of errors
58: */
59: public final void invoke(MessageContext messageContext,
60: Object endpoint) throws Exception {
61: invokeInternal(messageContext, (MethodEndpoint) endpoint);
62: }
63:
64: /**
65: * Given a method endpoint, return whether or not this adapter can support it.
66: *
67: * @param methodEndpoint method endpoint to check
68: * @return whether or not this adapter can adapt the given method
69: */
70: protected abstract boolean supportsInternal(
71: MethodEndpoint methodEndpoint);
72:
73: /**
74: * Use the given method endpoint to handle the request.
75: *
76: * @param messageContext the current message context
77: * @param methodEndpoint the method endpoint to use
78: * @throws Exception in case of errors
79: */
80: protected abstract void invokeInternal(
81: MessageContext messageContext, MethodEndpoint methodEndpoint)
82: throws Exception;
83:
84: }
|