1 /*
2 * Copyright 2005-2010 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.test.client;
18
19 import java.io.IOException;
20 import java.net.URI;
21
22 import org.springframework.ws.WebServiceMessage;
23 import org.springframework.ws.WebServiceMessageFactory;
24
25 /**
26 * Abstract base class for the {@link ResponseCreator} interface.
27 * <p/>
28 * Creates a response using the given {@link WebServiceMessageFactory}, and passes it on to {@link #doWithResponse(URI,
29 * WebServiceMessage, WebServiceMessage)}.
30 *
31 * @author Arjen Poutsma
32 * @since 2.0
33 */
34 abstract class AbstractResponseCreator implements ResponseCreator {
35
36 public final WebServiceMessage createResponse(URI uri,
37 WebServiceMessage request,
38 WebServiceMessageFactory messageFactory) throws IOException {
39 WebServiceMessage response = messageFactory.createWebServiceMessage();
40 doWithResponse(uri, request, response);
41 return response;
42 }
43
44 /**
45 * Execute any number of operations on the supplied response, given the request and URI.
46 *
47 * @param uri the URI
48 * @param request the request message
49 * @param response the response message
50 * @throws IOException in case of I/O errors
51 */
52 protected abstract void doWithResponse(URI uri, WebServiceMessage request, WebServiceMessage response)
53 throws IOException;
54
55 }