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.server.endpoint;
18
19 import javax.xml.stream.XMLInputFactory;
20 import javax.xml.stream.XMLOutputFactory;
21
22 import org.springframework.xml.transform.TransformerObjectSupport;
23
24 /**
25 * Abstract base class for endpoints use StAX. Provides an <code>XMLInputFactory</code> and an
26 * <code>XMLOutputFactory</code>.
27 *
28 * @author Arjen Poutsma
29 * @see XMLInputFactory
30 * @see XMLOutputFactory
31 * @since 1.0.0
32 * @deprecated as of Spring Web Services 2.0, in favor of annotated endpoints
33 */
34 @Deprecated
35 @SuppressWarnings("Since15")
36 public abstract class AbstractStaxPayloadEndpoint extends TransformerObjectSupport {
37
38 private XMLInputFactory inputFactory;
39
40 private XMLOutputFactory outputFactory;
41
42 /** Returns an <code>XMLInputFactory</code> to read XML from. */
43 protected final XMLInputFactory getInputFactory() {
44 if (inputFactory == null) {
45 inputFactory = createXmlInputFactory();
46 }
47 return inputFactory;
48 }
49
50 /** Returns an <code>XMLOutputFactory</code> to write XML to. */
51 protected final XMLOutputFactory getOutputFactory() {
52 if (outputFactory == null) {
53 outputFactory = createXmlOutputFactory();
54 }
55 return outputFactory;
56 }
57
58 /**
59 * Create a <code>XMLInputFactory</code> that this endpoint will use to create <code>XMLStreamReader</code>s or
60 * <code>XMLEventReader</code>. Can be overridden in subclasses, adding further initialization of the factory. The
61 * resulting <code>XMLInputFactory</code> is cached, so this method will only be called once.
62 *
63 * @return the created <code>XMLInputFactory</code>
64 */
65 protected XMLInputFactory createXmlInputFactory() {
66 return XMLInputFactory.newInstance();
67 }
68
69 /**
70 * Create a <code>XMLOutputFactory</code> that this endpoint will use to create <code>XMLStreamWriters</code>s or
71 * <code>XMLEventWriters</code>. Can be overridden in subclasses, adding further initialization of the factory. The
72 * resulting <code>XMLOutputFactory</code> is cached, so this method will only be called once.
73 *
74 * @return the created <code>XMLOutputFactory</code>
75 */
76 protected XMLOutputFactory createXmlOutputFactory() {
77 return XMLOutputFactory.newInstance();
78 }
79 }