01 /*
02 * $Id: SOAPConnectionFactory.java,v 1.4 2004/04/02 01:24:17 ofung Exp $
03 * $Revision: 1.4 $
04 * $Date: 2004/04/02 01:24:17 $
05 */
06
07 /*
08 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
09 * 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 = "com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory";
47
48 /**
49 * A constant representing the <code>SOAPConnection</code> class.
50 */
51 static private final String SF_PROPERTY = "javax.xml.soap.SOAPConnectionFactory";
52
53 /**
54 * Creates an instance of the default
55 * <code>SOAPConnectionFactory</code> object.
56 *
57 * @return a new instance of a default
58 * <code>SOAPConnectionFactory</code> object
59 *
60 * @exception SOAPException if there was an error creating the
61 * <code>SOAPConnectionFactory</code>
62 *
63 * @exception UnsupportedOperationException if newInstance is not
64 * supported.
65 */
66 public static SOAPConnectionFactory newInstance()
67 throws SOAPException, UnsupportedOperationException {
68 try {
69 return (SOAPConnectionFactory) FactoryFinder.find(
70 SF_PROPERTY, DEFAULT_SOAP_CONNECTION_FACTORY);
71 } catch (Exception ex) {
72 throw new SOAPException(
73 "Unable to create SOAP connection factory: "
74 + ex.getMessage());
75 }
76 }
77
78 /**
79 * Create a new <code>SOAPConnection</code>.
80 *
81 * @return the new <code>SOAPConnection</code> object.
82 *
83 * @exception SOAPException if there was an exception creating the
84 * <code>SOAPConnection</code> object.
85 */
86 public abstract SOAPConnection createConnection()
87 throws SOAPException;
88 }
|