1 /*
2 * $Id: SOAPConnectionFactory.java,v 1.4 2004/04/02 01:24:17 ofung Exp $
3 * $Revision: 1.4 $
4 * $Date: 2004/04/02 01:24:17 $
5 */
6
7 /*
8 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10 *
11 * This code is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 only, as
13 * published by the Free Software Foundation. Sun designates this
14 * particular file as subject to the "Classpath" exception as provided
15 * by Sun in the LICENSE file that accompanied this code.
16 *
17 * This code is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * version 2 for more details (a copy is included in the LICENSE file that
21 * accompanied this code).
22 *
23 * You should have received a copy of the GNU General Public License version
24 * 2 along with this work; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26 *
27 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
28 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * have any questions.
30 */
31 package javax.xml.soap;
32
33 /**
34 * A factory for creating <code>SOAPConnection</code> objects. Implementation of this class
35 * is optional. If <code>SOAPConnectionFactory.newInstance()</code> throws an
36 * UnsupportedOperationException then the implementation does not support the
37 * SAAJ communication infrastructure. Otherwise {@link SOAPConnection} objects
38 * can be created by calling <code>createConnection()</code> on the newly
39 * created <code>SOAPConnectionFactory</code> object.
40 */
41 public abstract class SOAPConnectionFactory {
42 /**
43 * A constant representing the default value for a <code>SOAPConnection</code>
44 * object. The default is the point-to-point SOAP connection.
45 */
46 static private final String DEFAULT_SOAP_CONNECTION_FACTORY
47 = "com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory";
48
49 /**
50 * A constant representing the <code>SOAPConnection</code> class.
51 */
52 static private final String SF_PROPERTY
53 = "javax.xml.soap.SOAPConnectionFactory";
54
55 /**
56 * Creates an instance of the default
57 * <code>SOAPConnectionFactory</code> object.
58 *
59 * @return a new instance of a default
60 * <code>SOAPConnectionFactory</code> object
61 *
62 * @exception SOAPException if there was an error creating the
63 * <code>SOAPConnectionFactory</code>
64 *
65 * @exception UnsupportedOperationException if newInstance is not
66 * supported.
67 */
68 public static SOAPConnectionFactory newInstance()
69 throws SOAPException, UnsupportedOperationException
70 {
71 try {
72 return (SOAPConnectionFactory)
73 FactoryFinder.find(SF_PROPERTY,
74 DEFAULT_SOAP_CONNECTION_FACTORY);
75 } catch (Exception ex) {
76 throw new SOAPException("Unable to create SOAP connection factory: "
77 +ex.getMessage());
78 }
79 }
80
81 /**
82 * Create a new <code>SOAPConnection</code>.
83 *
84 * @return the new <code>SOAPConnection</code> object.
85 *
86 * @exception SOAPException if there was an exception creating the
87 * <code>SOAPConnection</code> object.
88 */
89 public abstract SOAPConnection createConnection()
90 throws SOAPException;
91 }