001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package javax.xml.soap;
021
022 /**
023 * A factory for creating <code>SOAPConnection</code> objects. Implementation of
024 * this class is optional. If <code>SOAPConnectionFactory.newInstance()</code>
025 * throws an <code>UnsupportedOperationException</code> then the implementation
026 * does not support the SAAJ communication infrastructure. Otherwise
027 * <code>SOAPConnection</code> objects can be created by calling
028 * <code>createConnection()</code> on the newly created
029 * <code>SOAPConnectionFactory</code> object.
030 */
031 public abstract class SOAPConnectionFactory {
032
033 public SOAPConnectionFactory() {}
034
035 /**
036 * Creates an instance of the default <CODE>
037 * SOAPConnectionFactory</CODE> object.
038 * @return a new instance of a default <CODE>
039 * SOAPConnectionFactory</CODE> object
040 * @throws SOAPException if there was an error creating
041 * the <CODE>SOAPConnectionFactory
042 * @throws UnsupportedOperationException if newInstance is not supported.
043 */
044 public static SOAPConnectionFactory newInstance()
045 throws SOAPException, UnsupportedOperationException {
046
047 try {
048 return (SOAPConnectionFactory) FactoryFinder.find(SF_PROPERTY,
049 DEFAULT_SOAP_CONNECTION_FACTORY);
050 } catch (Exception exception) {
051 throw new SOAPException("Unable to create SOAP connection factory: "
052 + exception.getMessage());
053 }
054 }
055
056 /**
057 * Create a new <CODE>SOAPConnection</CODE>.
058 * @return the new <CODE>SOAPConnection</CODE> object.
059 * @throws SOAPException if there was an exception
060 * creating the <CODE>SOAPConnection</CODE> object.
061 */
062 public abstract SOAPConnection createConnection() throws SOAPException;
063
064 private static final String DEFAULT_SOAP_CONNECTION_FACTORY =
065 "org.apache.axis.soap.SOAPConnectionFactoryImpl";
066
067 private static final String SF_PROPERTY =
068 "javax.xml.soap.SOAPConnectionFactory";
069 }