KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > soap > SAAJMetaFactory


1 /*
2  * $Id: SAAJMetaFactory.java,v 1.4 2006/03/30 00:59:39 ofung Exp $
3  * $Revision: 1.4 $
4  * $Date: 2006/03/30 00:59:39 $
5  */

6
7 /*
8  * The contents of this file are subject to the terms
9  * of the Common Development and Distribution License
10  * (the License). You may not use this file except in
11  * compliance with the License.
12  *
13  * You can obtain a copy of the license at
14  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
15  * See the License for the specific language governing
16  * permissions and limitations under the License.
17  *
18  * When distributing Covered Code, include this CDDL
19  * Header Notice in each file and include the License file
20  * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
21  * If applicable, add the following below the CDDL Header,
22  * with the fields enclosed by brackets [] replaced by
23  * you own identifying information:
24  * "Portions Copyrighted [year] [name of copyright owner]"
25  *
26  * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
27  */

28 package javax.xml.soap;
29
30 /**
31 * The access point for the implementation classes of the factories defined in the
32 * SAAJ API. All of the <code>newInstance</code> methods defined on factories in
33 * SAAJ 1.3 defer to instances of this class to do the actual object creation.
34 * The implementations of <code>newInstance()</code> methods (in SOAPFactory and MessageFactory)
35 * that existed in SAAJ 1.2 have been updated to also delegate to the SAAJMetaFactory when the SAAJ 1.2
36 * defined lookup fails to locate the Factory implementation class name.
37 *
38 * <p>
39 * SAAJMetaFactory is a service provider interface. There are no public methods on this
40 * class.
41 *
42 * @author SAAJ RI Development Team
43 * @since SAAJ 1.3
44 */

45
46 public abstract class SAAJMetaFactory {
47     static private final String JavaDoc META_FACTORY_CLASS_PROPERTY =
48         "javax.xml.soap.MetaFactory";
49     static private final String JavaDoc DEFAULT_META_FACTORY_CLASS =
50         "com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl";
51
52     /**
53      * Creates a new instance of a concrete <code>SAAJMetaFactory</code> object.
54      * The SAAJMetaFactory is an SPI, it pulls the creation of the other factories together into a
55      * single place. Changing out the SAAJMetaFactory has the effect of changing out the entire SAAJ
56      * implementation. Service providers provide the name of their <code>SAAJMetaFactory</code>
57      * implementation.
58      *
59      * This method uses the following ordered lookup procedure to determine the SAAJMetaFactory implementation class to load:
60      * <UL>
61      * <LI> Use the javax.xml.soap.MetaFactory system property.
62      * <LI> Use the properties file "lib/jaxm.properties" in the JRE directory. This configuration file is in standard
63      * java.util.Properties format and contains the fully qualified name of the implementation class with the key being the
64      * system property defined above.
65      * <LI> Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API
66      * will look for a classname in the file META-INF/services/javax.xml.soap.MetaFactory in jars available to the runtime.
67      * <LI> Default to com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl.
68      * </UL>
69      *
70      * @return a concrete <code>SAAJMetaFactory</code> object
71      * @exception SOAPException if there is an error in creating the <code>SAAJMetaFactory</code>
72      */

73     static SAAJMetaFactory JavaDoc getInstance() throws SOAPException JavaDoc {
74             try {
75                 SAAJMetaFactory JavaDoc instance =
76                     (SAAJMetaFactory JavaDoc) FactoryFinder.find(
77                         META_FACTORY_CLASS_PROPERTY,
78                         DEFAULT_META_FACTORY_CLASS);
79                 return instance;
80             } catch (Exception JavaDoc e) {
81                 throw new SOAPException JavaDoc(
82                     "Unable to create SAAJ meta-factory" + e.getMessage());
83             }
84     }
85
86     protected SAAJMetaFactory() { }
87
88      /**
89       * Creates a <code>MessageFactory</code> object for
90       * the given <code>String</code> protocol.
91       *
92       * @param protocol a <code>String</code> indicating the protocol
93       * @exception SOAPException if there is an error in creating the
94       * MessageFactory
95       * @see SOAPConstants#SOAP_1_1_PROTOCOL
96       * @see SOAPConstants#SOAP_1_2_PROTOCOL
97       * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
98       */

99     protected abstract MessageFactory JavaDoc newMessageFactory(String JavaDoc protocol)
100         throws SOAPException JavaDoc;
101
102      /**
103       * Creates a <code>SOAPFactory</code> object for
104       * the given <code>String</code> protocol.
105       *
106       * @param protocol a <code>String</code> indicating the protocol
107       * @exception SOAPException if there is an error in creating the
108       * SOAPFactory
109       * @see SOAPConstants#SOAP_1_1_PROTOCOL
110       * @see SOAPConstants#SOAP_1_2_PROTOCOL
111       * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
112       */

113     protected abstract SOAPFactory JavaDoc newSOAPFactory(String JavaDoc protocol)
114         throws SOAPException JavaDoc;
115 }
116
Popular Tags