001: /*
002: * $Id: SAAJMetaFactory.java,v 1.5 2007/07/05 06:49:47 vj135062 Exp $
003: * $Revision: 1.5 $
004: * $Date: 2007/07/05 06:49:47 $
005: */
006:
007: /*
008: * The contents of this file are subject to the terms
009: * of the Common Development and Distribution License
010: * (the License). You may not use this file except in
011: * compliance with the License.
012: *
013: * You can obtain a copy of the license at
014: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
015: * See the License for the specific language governing
016: * permissions and limitations under the License.
017: *
018: * When distributing Covered Code, include this CDDL
019: * Header Notice in each file and include the License file
020: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
021: * If applicable, add the following below the CDDL Header,
022: * with the fields enclosed by brackets [] replaced by
023: * you own identifying information:
024: * "Portions Copyrighted [year] [name of copyright owner]"
025: *
026: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
027: */
028: package javax.xml.soap;
029:
030: /**
031: * The access point for the implementation classes of the factories defined in the
032: * SAAJ API. All of the <code>newInstance</code> methods defined on factories in
033: * SAAJ 1.3 defer to instances of this class to do the actual object creation.
034: * The implementations of <code>newInstance()</code> methods (in SOAPFactory and MessageFactory)
035: * that existed in SAAJ 1.2 have been updated to also delegate to the SAAJMetaFactory when the SAAJ 1.2
036: * defined lookup fails to locate the Factory implementation class name.
037: *
038: * <p>
039: * SAAJMetaFactory is a service provider interface. There are no public methods on this
040: * class.
041: *
042: * @author SAAJ RI Development Team
043: * @since SAAJ 1.3
044: */
045:
046: public abstract class SAAJMetaFactory {
047: static private final String META_FACTORY_CLASS_PROPERTY = "javax.xml.soap.MetaFactory";
048: static private final String DEFAULT_META_FACTORY_CLASS = "com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl";
049:
050: /**
051: * Creates a new instance of a concrete <code>SAAJMetaFactory</code> object.
052: * The SAAJMetaFactory is an SPI, it pulls the creation of the other factories together into a
053: * single place. Changing out the SAAJMetaFactory has the effect of changing out the entire SAAJ
054: * implementation. Service providers provide the name of their <code>SAAJMetaFactory</code>
055: * implementation.
056: *
057: * This method uses the following ordered lookup procedure to determine the SAAJMetaFactory implementation class to load:
058: * <UL>
059: * <LI> Use the javax.xml.soap.MetaFactory system property.
060: * <LI> Use the properties file "lib/jaxm.properties" in the JRE directory. This configuration file is in standard
061: * java.util.Properties format and contains the fully qualified name of the implementation class with the key being the
062: * system property defined above.
063: * <LI> Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API
064: * will look for a classname in the file META-INF/services/javax.xml.soap.MetaFactory in jars available to the runtime.
065: * <LI> Default to com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl.
066: * </UL>
067: *
068: * @return a concrete <code>SAAJMetaFactory</code> object
069: * @exception SOAPException if there is an error in creating the <code>SAAJMetaFactory</code>
070: */
071: static SAAJMetaFactory getInstance() throws SOAPException {
072: try {
073: SAAJMetaFactory instance = (SAAJMetaFactory) FactoryFinder
074: .find(META_FACTORY_CLASS_PROPERTY,
075: DEFAULT_META_FACTORY_CLASS);
076: return instance;
077: } catch (Exception e) {
078: throw new SOAPException(
079: "Unable to create SAAJ meta-factory"
080: + e.getMessage());
081: }
082: }
083:
084: protected SAAJMetaFactory() {
085: }
086:
087: /**
088: * Creates a <code>MessageFactory</code> object for
089: * the given <code>String</code> protocol.
090: *
091: * @param protocol a <code>String</code> indicating the protocol
092: * @exception SOAPException if there is an error in creating the
093: * MessageFactory
094: * @see SOAPConstants#SOAP_1_1_PROTOCOL
095: * @see SOAPConstants#SOAP_1_2_PROTOCOL
096: * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
097: */
098: protected abstract MessageFactory newMessageFactory(String protocol)
099: throws SOAPException;
100:
101: /**
102: * Creates a <code>SOAPFactory</code> object for
103: * the given <code>String</code> protocol.
104: *
105: * @param protocol a <code>String</code> indicating the protocol
106: * @exception SOAPException if there is an error in creating the
107: * SOAPFactory
108: * @see SOAPConstants#SOAP_1_1_PROTOCOL
109: * @see SOAPConstants#SOAP_1_2_PROTOCOL
110: * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
111: */
112: protected abstract SOAPFactory newSOAPFactory(String protocol)
113: throws SOAPException;
114: }
|