View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
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  package javax.xml.soap;
17  
18  /**
19   * A factory for creating <code>SOAPConnection</code> objects. Implementation of
20   * this class is optional. If <code>SOAPConnectionFactory.newInstance()</code>
21   * throws an <code>UnsupportedOperationException</code> then the implementation
22   * does not support the SAAJ communication infrastructure. Otherwise
23   * <code>SOAPConnection</code> objects can be created by calling
24   * <code>createConnection()</code> on the newly created
25   * <code>SOAPConnectionFactory</code> object.
26   */
27  public abstract class SOAPConnectionFactory {
28  
29      public SOAPConnectionFactory() {}
30  
31      /**
32       * Creates an instance of the default <CODE>
33       * SOAPConnectionFactory</CODE> object.
34       * @return a new instance of a default <CODE>
35       *     SOAPConnectionFactory</CODE> object
36       * @throws  SOAPException  if there was an error creating
37       *     the <CODE>SOAPConnectionFactory
38       * @throws UnsupportedOperationException  if newInstance is not supported.
39       */
40      public static SOAPConnectionFactory newInstance()
41              throws SOAPException, UnsupportedOperationException {
42  
43          try {
44              return (SOAPConnectionFactory) FactoryFinder.find(SF_PROPERTY,
45                      DEFAULT_SOAP_CONNECTION_FACTORY);
46          } catch (Exception exception) {
47              throw new SOAPException("Unable to create SOAP connection factory: "
48                                      + exception.getMessage());
49          }
50      }
51  
52      /**
53       * Create a new <CODE>SOAPConnection</CODE>.
54       * @return the new <CODE>SOAPConnection</CODE> object.
55       * @throws  SOAPException if there was an exception
56       *     creating the <CODE>SOAPConnection</CODE> object.
57       */
58      public abstract SOAPConnection createConnection() throws SOAPException;
59  
60      private static final String DEFAULT_SOAP_CONNECTION_FACTORY =
61          "org.apache.axis.soap.SOAPConnectionFactoryImpl";
62  
63      private static final String SF_PROPERTY =
64          "javax.xml.soap.SOAPConnectionFactory";
65  }