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