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.client.core;
18
19 import java.io.IOException;
20 import javax.xml.transform.Source;
21 import javax.xml.transform.TransformerException;
22
23 /**
24 * Callback interface for extracting a result object from a {@link javax.xml.transform.Source} instance.
25 * <p/>
26 * Used for output object creation in {@link WebServiceTemplate}. Alternatively, output sources can also be returned to
27 * client code as-is. In case of a source as execution result, you will almost always want to implement a
28 * <code>SourceExtractor</code>, to be able to read the message content in a managed fashion, with the connection still
29 * open while reading the message.
30 * <p/>
31 * Implementations of this interface perform the actual work of extracting results, but don't need to worry about
32 * exception handling, or resource handling.
33 *
34 * @author Arjen Poutsma
35 * @see org.springframework.ws.client.core.WebServiceTemplate
36 * @since 1.0.0
37 */
38 public interface SourceExtractor<T> {
39
40 /**
41 * Process the data in the given <code>Source</code>, creating a corresponding result object.
42 *
43 * @param source the message payload to extract data from
44 * @return an arbitrary result object, or <code>null</code> if none (the extractor will typically be stateful in the
45 * latter case)
46 * @throws IOException in case of I/O errors
47 */
48 T extractData(Source source) throws IOException, TransformerException;
49
50 }