author | mkos |
Fri, 27 Nov 2015 11:28:43 +0100 | |
changeset 34467 | 024f1ce7da02 |
child 45678 | 65fdff10664d |
permissions | -rw-r--r-- |
34467
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
1 |
/* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
2 |
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
4 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
10 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
15 |
* accompanied this code). |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
16 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
20 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
23 |
* questions. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
24 |
*/ |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
25 |
|
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
26 |
/** |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
27 |
* Provides the API for creating and building SOAP messages. This package |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
28 |
* is defined in the <i>SOAP with Attachments API for Java<sup><font size="-2">TM</font></sup> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
29 |
* (SAAJ) 1.4</i> specification. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
30 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
31 |
* <p> The API in the <code>javax.xml.soap</code> package allows you to do the following: |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
32 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
33 |
* <ul> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
34 |
* <li>create a point-to-point connection to a specified endpoint |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
35 |
* <li>create a SOAP message |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
36 |
* <li>create an XML fragment |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
37 |
* <li>add content to the header of a SOAP message |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
38 |
* <li>add content to the body of a SOAP message |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
39 |
* <li>create attachment parts and add content to them |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
40 |
* <li>access/add/modify parts of a SOAP message |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
41 |
* <li>create/add/modify SOAP fault information |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
42 |
* <li>extract content from a SOAP message |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
43 |
* <li>send a SOAP request-response message |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
44 |
* </ul> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
45 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
46 |
* <p> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
47 |
* In addition the APIs in the <code>javax.xml.soap</code> package extend |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
48 |
* their counterparts in the <code>org.w3c.dom</code> package. This means that |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
49 |
* the <code>SOAPPart</code> of a <code>SOAPMessage</code> is also a DOM Level |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
50 |
* 2 <code>Document</code>, and can be manipulated as such by applications, |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
51 |
* tools and libraries that use DOM (see http://www.w3.org/DOM/ for more information). |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
52 |
* It is important to note that, while it is possible to use DOM APIs to add |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
53 |
* ordinary DOM nodes to a SAAJ tree, the SAAJ APIs are still required to return |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
54 |
* SAAJ types when examining or manipulating the tree. In order to accomplish |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
55 |
* this the SAAJ APIs (specifically {@link javax.xml.soap.SOAPElement#getChildElements()}) |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
56 |
* are allowed to silently replace objects that are incorrectly typed relative |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
57 |
* to SAAJ requirements with equivalent objects of the required type. These |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
58 |
* replacements must never cause the logical structure of the tree to change, |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
59 |
* so from the perspective of the DOM APIs the tree will remain unchanged. However, |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
60 |
* the physical composition of the tree will have changed so that references |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
61 |
* to the nodes that were replaced will refer to nodes that are no longer a |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
62 |
* part of the tree. The SAAJ APIs are not allowed to make these replacements |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
63 |
* if they are not required so the replacement objects will never subsequently |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
64 |
* be silently replaced by future calls to the SAAJ API. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
65 |
* <p> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
66 |
* What this means in practical terms is that an application that starts to use |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
67 |
* SAAJ APIs on a tree after manipulating it using DOM APIs must assume that the |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
68 |
* tree has been translated into an all SAAJ tree and that any references to objects |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
69 |
* within the tree that were obtained using DOM APIs are no longer valid. Switching |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
70 |
* from SAAJ APIs to DOM APIs is not allowed to cause invalid references and |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
71 |
* neither is using SAAJ APIs exclusively. It is only switching from using DOM |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
72 |
* APIs on a particular SAAJ tree to using SAAJ APIs that causes the risk of |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
73 |
* invalid references. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
74 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
75 |
* <h3>Discovery of SAAJ implementation</h3> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
76 |
* <p> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
77 |
* There are several factories defined in the SAAJ API to discover and load specific implementation: |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
78 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
79 |
* <ul> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
80 |
* <li>{@link javax.xml.soap.SOAPFactory} |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
81 |
* <li>{@link javax.xml.soap.MessageFactory} |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
82 |
* <li>{@link javax.xml.soap.SOAPConnectionFactory} |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
83 |
* <li>{@link javax.xml.soap.SAAJMetaFactory} |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
84 |
* </ul> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
85 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
86 |
* First three define {@code newInstance()} method which uses a common lookup procedure to determine |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
87 |
* the implementation class: |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
88 |
* |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
89 |
* <ul> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
90 |
* <li>Checks if a system property with the same name as the factory class is set (e.g. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
91 |
* {@code javax.xml.soap.SOAPFactory}). If such property exists then its value is assumed to be the fully qualified |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
92 |
* name of the implementation class. This phase of the look up enables per-JVM override of the SAAJ implementation. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
93 |
* <li>Use the configuration file "jaxm.properties". The file is in standard |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
94 |
* {@link java.util.Properties} format and typically located in the |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
95 |
* {@code conf} directory of the Java installation. It contains the fully qualified |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
96 |
* name of the implementation class with the key being the system property |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
97 |
* defined above. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
98 |
* <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:
diff
changeset
|
99 |
* 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:
diff
changeset
|
100 |
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
101 |
* <li> Finally, if all the steps above fail, {@link javax.xml.soap.SAAJMetaFactory} instance is used |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
102 |
* to locate specific implementation (for {@link javax.xml.soap.MessageFactory} and {@link javax.xml.soap.SOAPFactory}) |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
103 |
* or platform default implementation is used ({@link javax.xml.soap.SOAPConnectionFactory}). |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
104 |
* Whenever {@link javax.xml.soap.SAAJMetaFactory} is used, its lookup procedure to get actual instance is performed. |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
105 |
* </ul> |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
106 |
*/ |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
diff
changeset
|
107 |
package javax.xml.soap; |