jaxws/src/java.xml.ws/share/classes/javax/xml/soap/SAAJMetaFactory.java
author lana
Thu, 11 Aug 2016 15:47:07 +0000
changeset 40243 225732b21228
parent 34467 024f1ce7da02
child 45678 65fdff10664d
permissions -rw-r--r--
Added tag jdk-9+131 for changeset 2bf4f6d6a72f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     1
/*
31746
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
     2
 * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     4
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    10
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    15
 * accompanied this code).
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    16
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    20
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    23
 * questions.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    24
 */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    25
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    26
package javax.xml.soap;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    27
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    28
/**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    29
* The access point for the implementation classes of the factories defined in the
34467
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    30
* SAAJ API. The {@code newInstance} methods defined on factories {@link SOAPFactory} and
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    31
* {@link MessageFactory} in SAAJ 1.3 defer to instances of this class to do the actual object creation.
31746
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
    32
* The implementations of {@code newInstance()} methods (in SOAPFactory and MessageFactory)
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    33
* that existed in SAAJ 1.2 have been updated to also delegate to the SAAJMetaFactory when the SAAJ 1.2
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    34
* defined lookup fails to locate the Factory implementation class name.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    35
*
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    36
* <p>
34467
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    37
* SAAJMetaFactory is a service provider interface and it uses similar lookup mechanism as other SAAJ factories
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    38
* to get actual instance:
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    39
*
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    40
* <ul>
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    41
*  <li>If a system property with name {@code javax.xml.soap.SAAJMetaFactory} exists then its value is assumed
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    42
*  to be the fully qualified name of the implementation class. This phase of the look up enables per-JVM
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    43
*  override of the SAAJ implementation.
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    44
*  <li>If a system property with name {@code javax.xml.soap.MetaFactory} exists then its value is assumed
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    45
*  to be the fully qualified name of the implementation class. This property, defined by previous specifications
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    46
 * (up to 1.3), is still supported, but it is strongly recommended to migrate to new property
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    47
 * {@code javax.xml.soap.SAAJMetaFactory}.
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    48
*  <li>Use the configuration file "jaxm.properties". The file is in standard {@link java.util.Properties} format
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    49
*  and typically located in the {@code conf} directory of the Java installation. It contains the fully qualified
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    50
*  name of the implementation class with key {@code javax.xml.soap.SAAJMetaFactory}. If no such property is defined,
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    51
 * again, property with key {@code javax.xml.soap.MetaFactory} is used. It is strongly recommended to migrate to
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    52
 * new property {@code javax.xml.soap.SAAJMetaFactory}.
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    53
*  <li> Use the service-provider loading facilities, defined by the {@link java.util.ServiceLoader} class,
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    54
*  to attempt to locate and load an implementation of the service using the {@linkplain
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    55
*  java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}.
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    56
*  <li> Finally, if all the steps above fail, platform default implementation is used.
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    57
* </ul>
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    58
*
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    59
* <p>
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    60
* There are no public methods on this
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    61
* class.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    62
*
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    63
* @author SAAJ RI Development Team
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 18372
diff changeset
    64
* @since 1.6, SAAJ 1.3
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    65
*/
34467
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    66
public abstract class SAAJMetaFactory {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    67
34467
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    68
    private static final String META_FACTORY_DEPRECATED_CLASS_PROPERTY =
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    69
            "javax.xml.soap.MetaFactory";
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    70
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    71
    private static final String DEFAULT_META_FACTORY_CLASS =
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    72
            "com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl";
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    73
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    74
    /**
31746
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
    75
     * Creates a new instance of a concrete {@code SAAJMetaFactory} object.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    76
     * The SAAJMetaFactory is an SPI, it pulls the creation of the other factories together into a
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    77
     * single place. Changing out the SAAJMetaFactory has the effect of changing out the entire SAAJ
31746
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
    78
     * implementation. Service providers provide the name of their {@code SAAJMetaFactory}
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    79
     * implementation.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    80
     *
34467
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    81
     * This method uses the lookup procedure specified in {@link javax.xml.soap} to locate and load the
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    82
     * {@link javax.xml.soap.SAAJMetaFactory} class.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    83
     *
31746
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
    84
     * @return a concrete {@code SAAJMetaFactory} object
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
    85
     * @exception SOAPException if there is an error in creating the {@code SAAJMetaFactory}
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    86
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    87
    static SAAJMetaFactory getInstance() throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    88
            try {
34467
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    89
                return FactoryFinder.find(
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    90
                        SAAJMetaFactory.class,
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    91
                        DEFAULT_META_FACTORY_CLASS,
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    92
                        true,
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    93
                        META_FACTORY_DEPRECATED_CLASS_PROPERTY);
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
    94
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    95
            } catch (Exception e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    96
                throw new SOAPException(
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    97
                    "Unable to create SAAJ meta-factory" + e.getMessage());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    98
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    99
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   100
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   101
    protected SAAJMetaFactory() { }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   102
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   103
     /**
31746
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
   104
      * Creates a {@code MessageFactory} object for
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
   105
      * the given {@code String} protocol.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   106
      *
31746
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
   107
      * @param protocol a {@code String} indicating the protocol
34467
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
   108
      * @return a {@link MessageFactory}, not null
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   109
      * @exception SOAPException if there is an error in creating the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   110
      *            MessageFactory
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   111
      * @see SOAPConstants#SOAP_1_1_PROTOCOL
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   112
      * @see SOAPConstants#SOAP_1_2_PROTOCOL
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   113
      * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   114
      */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   115
    protected abstract MessageFactory newMessageFactory(String protocol)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   116
        throws SOAPException;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   117
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   118
     /**
31746
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
   119
      * Creates a {@code SOAPFactory} object for
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
   120
      * the given {@code String} protocol.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   121
      *
31746
7573de6b8e46 8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents: 28326
diff changeset
   122
      * @param protocol a {@code String} indicating the protocol
34467
024f1ce7da02 8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents: 31746
diff changeset
   123
      * @return a {@link SOAPFactory}, not null
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   124
      * @exception SOAPException if there is an error in creating the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   125
      *            SOAPFactory
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   126
      * @see SOAPConstants#SOAP_1_1_PROTOCOL
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   127
      * @see SOAPConstants#SOAP_1_2_PROTOCOL
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   128
      * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   129
      */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   130
    protected abstract SOAPFactory newSOAPFactory(String protocol)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   131
        throws SOAPException;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   132
}