01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package javax.xml.soap;
20:
21: /**
22: * A factory for creating <code>SOAPConnection</code> objects. Implementation of this class is
23: * optional. If <code>SOAPConnectionFactory.newInstance()</code> throws an
24: * <code>UnsupportedOperationException</code> then the implementation does not support the SAAJ
25: * communication infrastructure. Otherwise <code>SOAPConnection</code> objects can be created by
26: * calling <code>createConnection()</code> on the newly created <code>SOAPConnectionFactory</code>
27: * object.
28: */
29: public abstract class SOAPConnectionFactory {
30:
31: public SOAPConnectionFactory() {
32: }
33:
34: /**
35: * Creates an instance of the default <CODE> SOAPConnectionFactory</CODE> object.
36: *
37: * @return a new instance of a default <CODE> SOAPConnectionFactory</CODE> object
38: * @throws SOAPException if there was an error creating the <CODE>SOAPConnectionFactory
39: * @throws UnsupportedOperationException if newInstance is not supported.
40: */
41: public static SOAPConnectionFactory newInstance()
42: throws SOAPException, UnsupportedOperationException {
43:
44: try {
45: return (SOAPConnectionFactory) FactoryFinder.find(
46: SF_PROPERTY, DEFAULT_SOAP_CONNECTION_FACTORY);
47: } catch (Exception exception) {
48: throw new SOAPException(
49: "Unable to create SOAP connection factory: "
50: + exception.getMessage());
51: }
52: }
53:
54: /**
55: * Create a new <CODE>SOAPConnection</CODE>.
56: *
57: * @return the new <CODE>SOAPConnection</CODE> object.
58: * @throws SOAPException if there was an exception creating the <CODE>SOAPConnection</CODE>
59: * object.
60: */
61: public abstract SOAPConnection createConnection()
62: throws SOAPException;
63:
64: private static final String DEFAULT_SOAP_CONNECTION_FACTORY = "org.apache.axis2.saaj.SOAPConnectionFactoryImpl";
65:
66: private static final String SF_PROPERTY = "javax.xml.soap.SOAPConnectionFactory";
67: }
|