Tue, 09 Apr 2013 14:51:13 +0100
8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com
1 /*
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 */
26 package javax.xml.soap;
28 import javax.xml.namespace.QName;
30 import org.w3c.dom.Element;
32 /**
33 * <code>SOAPFactory</code> is a factory for creating various objects
34 * that exist in the SOAP XML tree.
36 * <code>SOAPFactory</code> can be
37 * used to create XML fragments that will eventually end up in the
38 * SOAP part. These fragments can be inserted as children of the
39 * {@link SOAPHeaderElement} or {@link SOAPBodyElement} or
40 * {@link SOAPEnvelope} or other {@link SOAPElement} objects.
41 *
42 * <code>SOAPFactory</code> also has methods to create
43 * <code>javax.xml.soap.Detail</code> objects as well as
44 * <code>java.xml.soap.Name</code> objects.
45 *
46 */
47 public abstract class SOAPFactory {
49 /**
50 * A constant representing the property used to lookup the name of
51 * a <code>SOAPFactory</code> implementation class.
52 */
53 static private final String SOAP_FACTORY_PROPERTY =
54 "javax.xml.soap.SOAPFactory";
56 /**
57 * A constant representing the name of the default <code>SOAPFactory</code>
58 * factory class to be used if another cannot be found.
59 * a <code>SOAPFactory</code> implementation class.
60 */
61 static private final String DEFAULT_SOAP_FACTORY
62 = "com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl";
64 /**
65 * Creates a <code>SOAPElement</code> object from an existing DOM
66 * <code>Element</code>. If the DOM <code>Element</code> that is passed in
67 * as an argument is already a <code>SOAPElement</code> then this method
68 * must return it unmodified without any further work. Otherwise, a new
69 * <code>SOAPElement</code> is created and a deep copy is made of the
70 * <code>domElement</code> argument. The concrete type of the return value
71 * will depend on the name of the <code>domElement</code> argument. If any
72 * part of the tree rooted in <code>domElement</code> violates SOAP rules, a
73 * <code>SOAPException</code> will be thrown.
74 *
75 * @param domElement - the <code>Element</code> to be copied.
76 *
77 * @return a new <code>SOAPElement</code> that is a copy of <code>domElement</code>.
78 *
79 * @exception SOAPException if there is an error in creating the
80 * <code>SOAPElement</code> object
81 *
82 * @since SAAJ 1.3
83 */
84 public SOAPElement createElement(Element domElement) throws SOAPException {
85 throw new UnsupportedOperationException("createElement(org.w3c.dom.Element) must be overridden by all subclasses of SOAPFactory.");
86 }
88 /**
89 * Creates a <code>SOAPElement</code> object initialized with the
90 * given <code>Name</code> object. The concrete type of the return value
91 * will depend on the name given to the new <code>SOAPElement</code>. For
92 * instance, a new <code>SOAPElement</code> with the name
93 * "{http://www.w3.org/2003/05/soap-envelope}Envelope" would cause a
94 * <code>SOAPEnvelope</code> that supports SOAP 1.2 behavior to be created.
95 *
96 * @param name a <code>Name</code> object with the XML name for
97 * the new element
98 *
99 * @return the new <code>SOAPElement</code> object that was
100 * created
101 *
102 * @exception SOAPException if there is an error in creating the
103 * <code>SOAPElement</code> object
104 * @see SOAPFactory#createElement(javax.xml.namespace.QName)
105 */
106 public abstract SOAPElement createElement(Name name) throws SOAPException;
108 /**
109 * Creates a <code>SOAPElement</code> object initialized with the
110 * given <code>QName</code> object. The concrete type of the return value
111 * will depend on the name given to the new <code>SOAPElement</code>. For
112 * instance, a new <code>SOAPElement</code> with the name
113 * "{http://www.w3.org/2003/05/soap-envelope}Envelope" would cause a
114 * <code>SOAPEnvelope</code> that supports SOAP 1.2 behavior to be created.
115 *
116 * @param qname a <code>QName</code> object with the XML name for
117 * the new element
118 *
119 * @return the new <code>SOAPElement</code> object that was
120 * created
121 *
122 * @exception SOAPException if there is an error in creating the
123 * <code>SOAPElement</code> object
124 * @see SOAPFactory#createElement(Name)
125 * @since SAAJ 1.3
126 */
127 public SOAPElement createElement(QName qname) throws SOAPException {
128 throw new UnsupportedOperationException("createElement(QName) must be overridden by all subclasses of SOAPFactory.");
129 }
131 /**
132 * Creates a <code>SOAPElement</code> object initialized with the
133 * given local name.
134 *
135 * @param localName a <code>String</code> giving the local name for
136 * the new element
137 *
138 * @return the new <code>SOAPElement</code> object that was
139 * created
140 *
141 * @exception SOAPException if there is an error in creating the
142 * <code>SOAPElement</code> object
143 */
144 public abstract SOAPElement createElement(String localName)
145 throws SOAPException;
148 /**
149 * Creates a new <code>SOAPElement</code> object with the given
150 * local name, prefix and uri. The concrete type of the return value
151 * will depend on the name given to the new <code>SOAPElement</code>. For
152 * instance, a new <code>SOAPElement</code> with the name
153 * "{http://www.w3.org/2003/05/soap-envelope}Envelope" would cause a
154 * <code>SOAPEnvelope</code> that supports SOAP 1.2 behavior to be created.
155 *
156 * @param localName a <code>String</code> giving the local name
157 * for the new element
158 * @param prefix the prefix for this <code>SOAPElement</code>
159 * @param uri a <code>String</code> giving the URI of the
160 * namespace to which the new element belongs
161 *
162 * @exception SOAPException if there is an error in creating the
163 * <code>SOAPElement</code> object
164 */
165 public abstract SOAPElement createElement(
166 String localName,
167 String prefix,
168 String uri)
169 throws SOAPException;
171 /**
172 * Creates a new <code>Detail</code> object which serves as a container
173 * for <code>DetailEntry</code> objects.
174 * <P>
175 * This factory method creates <code>Detail</code> objects for use in
176 * situations where it is not practical to use the <code>SOAPFault</code>
177 * abstraction.
178 *
179 * @return a <code>Detail</code> object
180 * @throws SOAPException if there is a SOAP error
181 * @throws UnsupportedOperationException if the protocol specified
182 * for the SOAPFactory was <code>DYNAMIC_SOAP_PROTOCOL</code>
183 */
184 public abstract Detail createDetail() throws SOAPException;
186 /**
187 *Creates a new <code>SOAPFault</code> object initialized with the given <code>reasonText</code>
188 * and <code>faultCode</code>
189 *@param reasonText the ReasonText/FaultString for the fault
190 *@param faultCode the FaultCode for the fault
191 *@return a <code>SOAPFault</code> object
192 *@throws SOAPException if there is a SOAP error
193 *@since SAAJ 1.3
194 */
195 public abstract SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException;
197 /**
198 *Creates a new default <code>SOAPFault</code> object
199 *@return a <code>SOAPFault</code> object
200 *@throws SOAPException if there is a SOAP error
201 *@since SAAJ 1.3
202 */
203 public abstract SOAPFault createFault() throws SOAPException;
205 /**
206 * Creates a new <code>Name</code> object initialized with the
207 * given local name, namespace prefix, and namespace URI.
208 * <P>
209 * This factory method creates <code>Name</code> objects for use in
210 * situations where it is not practical to use the <code>SOAPEnvelope</code>
211 * abstraction.
212 *
213 * @param localName a <code>String</code> giving the local name
214 * @param prefix a <code>String</code> giving the prefix of the namespace
215 * @param uri a <code>String</code> giving the URI of the namespace
216 * @return a <code>Name</code> object initialized with the given
217 * local name, namespace prefix, and namespace URI
218 * @throws SOAPException if there is a SOAP error
219 */
220 public abstract Name createName(
221 String localName,
222 String prefix,
223 String uri)
224 throws SOAPException;
226 /**
227 * Creates a new <code>Name</code> object initialized with the
228 * given local name.
229 * <P>
230 * This factory method creates <code>Name</code> objects for use in
231 * situations where it is not practical to use the <code>SOAPEnvelope</code>
232 * abstraction.
233 *
234 * @param localName a <code>String</code> giving the local name
235 * @return a <code>Name</code> object initialized with the given
236 * local name
237 * @throws SOAPException if there is a SOAP error
238 */
239 public abstract Name createName(String localName) throws SOAPException;
241 /**
242 * Creates a new <code>SOAPFactory</code> object that is an instance of
243 * the default implementation (SOAP 1.1),
244 *
245 * This method uses the following ordered lookup procedure to determine the SOAPFactory implementation class to load:
246 * <UL>
247 * <LI> Use the javax.xml.soap.SOAPFactory system property.
248 * <LI> Use the properties file "lib/jaxm.properties" in the JRE directory. This configuration file is in standard
249 * java.util.Properties format and contains the fully qualified name of the implementation class with the key being the
250 * system property defined above.
251 * <LI> Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API
252 * will look for a classname in the file META-INF/services/javax.xml.soap.SOAPFactory in jars available to the runtime.
253 * <LI> Use the SAAJMetaFactory instance to locate the SOAPFactory implementation class.
254 * </UL>
255 *
256 * @return a new instance of a <code>SOAPFactory</code>
257 *
258 * @exception SOAPException if there was an error creating the
259 * default <code>SOAPFactory</code>
260 * @see SAAJMetaFactory
261 */
262 public static SOAPFactory newInstance()
263 throws SOAPException
264 {
265 try {
266 SOAPFactory factory = (SOAPFactory) FactoryFinder.find(
267 SOAP_FACTORY_PROPERTY, DEFAULT_SOAP_FACTORY, false);
268 if (factory != null)
269 return factory;
270 return newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
271 } catch (Exception ex) {
272 throw new SOAPException(
273 "Unable to create SOAP Factory: " + ex.getMessage());
274 }
276 }
278 /**
279 * Creates a new <code>SOAPFactory</code> object that is an instance of
280 * the specified implementation, this method uses the SAAJMetaFactory to
281 * locate the implementation class and create the SOAPFactory instance.
282 *
283 * @return a new instance of a <code>SOAPFactory</code>
284 *
285 * @param protocol a string constant representing the protocol of the
286 * specified SOAP factory implementation. May be
287 * either <code>DYNAMIC_SOAP_PROTOCOL</code>,
288 * <code>DEFAULT_SOAP_PROTOCOL</code> (which is the same
289 * as) <code>SOAP_1_1_PROTOCOL</code>, or
290 * <code>SOAP_1_2_PROTOCOL</code>.
291 *
292 * @exception SOAPException if there was an error creating the
293 * specified <code>SOAPFactory</code>
294 * @see SAAJMetaFactory
295 * @since SAAJ 1.3
296 */
297 public static SOAPFactory newInstance(String protocol)
298 throws SOAPException {
299 return SAAJMetaFactory.getInstance().newSOAPFactory(protocol);
300 }
301 }