< prev index next >

src/java.xml.ws/share/classes/javax/xml/soap/SAAJMetaFactory.java

Print this page




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.xml.soap;
  27 
  28 /**
  29 * The access point for the implementation classes of the factories defined in the
  30 * SAAJ API. All of the {@code newInstance} methods defined on factories in
  31 * SAAJ 1.3 defer to instances of this class to do the actual object creation.
  32 * The implementations of {@code newInstance()} methods (in SOAPFactory and MessageFactory)
  33 * that existed in SAAJ 1.2 have been updated to also delegate to the SAAJMetaFactory when the SAAJ 1.2
  34 * defined lookup fails to locate the Factory implementation class name.
  35 *
  36 * <p>
  37 * SAAJMetaFactory is a service provider interface. There are no public methods on this























  38 * class.
  39 *
  40 * @author SAAJ RI Development Team
  41 * @since 1.6, SAAJ 1.3
  42 */
  43 
  44 public abstract class SAAJMetaFactory {
  45     static private final String META_FACTORY_CLASS_PROPERTY =

  46         "javax.xml.soap.MetaFactory";
  47     static final String DEFAULT_META_FACTORY_CLASS =

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

  78             } catch (Exception e) {
  79                 throw new SOAPException(
  80                     "Unable to create SAAJ meta-factory" + e.getMessage());
  81             }
  82     }
  83 
  84     protected SAAJMetaFactory() { }
  85 
  86      /**
  87       * Creates a {@code MessageFactory} object for
  88       * the given {@code String} protocol.
  89       *
  90       * @param protocol a {@code String} indicating the protocol

  91       * @exception SOAPException if there is an error in creating the
  92       *            MessageFactory
  93       * @see SOAPConstants#SOAP_1_1_PROTOCOL
  94       * @see SOAPConstants#SOAP_1_2_PROTOCOL
  95       * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
  96       */
  97     protected abstract MessageFactory newMessageFactory(String protocol)
  98         throws SOAPException;
  99 
 100      /**
 101       * Creates a {@code SOAPFactory} object for
 102       * the given {@code String} protocol.
 103       *
 104       * @param protocol a {@code String} indicating the protocol

 105       * @exception SOAPException if there is an error in creating the
 106       *            SOAPFactory
 107       * @see SOAPConstants#SOAP_1_1_PROTOCOL
 108       * @see SOAPConstants#SOAP_1_2_PROTOCOL
 109       * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
 110       */
 111     protected abstract SOAPFactory newSOAPFactory(String protocol)
 112         throws SOAPException;
 113 }


  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.xml.soap;
  27 
  28 /**
  29 * The access point for the implementation classes of the factories defined in the
  30 * SAAJ API. The {@code newInstance} methods defined on factories {@link SOAPFactory} and
  31 * {@link MessageFactory} in SAAJ 1.3 defer to instances of this class to do the actual object creation.
  32 * The implementations of {@code newInstance()} methods (in SOAPFactory and MessageFactory)
  33 * that existed in SAAJ 1.2 have been updated to also delegate to the SAAJMetaFactory when the SAAJ 1.2
  34 * defined lookup fails to locate the Factory implementation class name.
  35 *
  36 * <p>
  37 * SAAJMetaFactory is a service provider interface and it uses similar lookup mechanism as other SAAJ factories
  38 * to get actual instance:
  39 *
  40 * <ul>
  41 *  <li>If a system property with name {@code javax.xml.soap.SAAJMetaFactory} exists then its value is assumed
  42 *  to be the fully qualified name of the implementation class. This phase of the look up enables per-JVM
  43 *  override of the SAAJ implementation.
  44 *  <li>If a system property with name {@code javax.xml.soap.MetaFactory} exists then its value is assumed
  45 *  to be the fully qualified name of the implementation class. This property, defined by previous specifications
  46  * (up to 1.3), is still supported, but it is strongly recommended to migrate to new property
  47  * {@code javax.xml.soap.SAAJMetaFactory}.
  48 *  <li>Use the configuration file "jaxm.properties". The file is in standard {@link java.util.Properties} format
  49 *  and typically located in the {@code conf} directory of the Java installation. It contains the fully qualified
  50 *  name of the implementation class with key {@code javax.xml.soap.SAAJMetaFactory}. If no such property is defined,
  51  * again, property with key {@code javax.xml.soap.MetaFactory} is used. It is strongly recommended to migrate to
  52  * new property {@code javax.xml.soap.SAAJMetaFactory}.
  53 *  <li> Use the service-provider loading facilities, defined by the {@link java.util.ServiceLoader} class,
  54 *  to attempt to locate and load an implementation of the service using the {@linkplain
  55 *  java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}.
  56 *  <li> Finally, if all the steps above fail, platform default implementation is used.
  57 * </ul>
  58 *
  59 * <p>
  60 * There are no public methods on this
  61 * class.
  62 *
  63 * @author SAAJ RI Development Team
  64 * @since 1.6, SAAJ 1.3
  65 */

  66 public abstract class SAAJMetaFactory {
  67 
  68     private static final String META_FACTORY_DEPRECATED_CLASS_PROPERTY =
  69             "javax.xml.soap.MetaFactory";
  70 
  71     private static final String DEFAULT_META_FACTORY_CLASS =
  72             "com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl";
  73 
  74     /**
  75      * Creates a new instance of a concrete {@code SAAJMetaFactory} object.
  76      * The SAAJMetaFactory is an SPI, it pulls the creation of the other factories together into a
  77      * single place. Changing out the SAAJMetaFactory has the effect of changing out the entire SAAJ
  78      * implementation. Service providers provide the name of their {@code SAAJMetaFactory}
  79      * implementation.
  80      *
  81      * This method uses the lookup procedure specified in {@link javax.xml.soap} to locate and load the
  82      * {@link javax.xml.soap.SAAJMetaFactory} class.








  83      *
  84      * @return a concrete {@code SAAJMetaFactory} object
  85      * @exception SOAPException if there is an error in creating the {@code SAAJMetaFactory}
  86      */
  87     static SAAJMetaFactory getInstance() throws SOAPException {
  88             try {
  89                 return FactoryFinder.find(
  90                         SAAJMetaFactory.class,
  91                         DEFAULT_META_FACTORY_CLASS,
  92                         true,
  93                         META_FACTORY_DEPRECATED_CLASS_PROPERTY);
  94 
  95             } catch (Exception e) {
  96                 throw new SOAPException(
  97                     "Unable to create SAAJ meta-factory" + e.getMessage());
  98             }
  99     }
 100 
 101     protected SAAJMetaFactory() { }
 102 
 103      /**
 104       * Creates a {@code MessageFactory} object for
 105       * the given {@code String} protocol.
 106       *
 107       * @param protocol a {@code String} indicating the protocol
 108       * @return a {@link MessageFactory}, not null
 109       * @exception SOAPException if there is an error in creating the
 110       *            MessageFactory
 111       * @see SOAPConstants#SOAP_1_1_PROTOCOL
 112       * @see SOAPConstants#SOAP_1_2_PROTOCOL
 113       * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
 114       */
 115     protected abstract MessageFactory newMessageFactory(String protocol)
 116         throws SOAPException;
 117 
 118      /**
 119       * Creates a {@code SOAPFactory} object for
 120       * the given {@code String} protocol.
 121       *
 122       * @param protocol a {@code String} indicating the protocol
 123       * @return a {@link SOAPFactory}, not null
 124       * @exception SOAPException if there is an error in creating the
 125       *            SOAPFactory
 126       * @see SOAPConstants#SOAP_1_1_PROTOCOL
 127       * @see SOAPConstants#SOAP_1_2_PROTOCOL
 128       * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
 129       */
 130     protected abstract SOAPFactory newSOAPFactory(String protocol)
 131         throws SOAPException;
 132 }
< prev index next >