jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java
author aefimov
Sun, 18 Jun 2017 23:07:25 +0100
changeset 45678 65fdff10664d
parent 42124 640a383428fb
permissions -rw-r--r--
8176508: Update JAX-WS RI integration to latest version Reviewed-by: lancea, mchung, alanb, iris
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
/*
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
     2
 * Copyright (c) 2003, 2017, 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.bind;
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
import org.w3c.dom.Node;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    29
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
    30
import java.io.IOException;
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
    31
import java.io.InputStream;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    32
import java.util.Collections;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    33
import java.util.Map;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    34
import java.util.Properties;
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
/**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
    37
 * The {@code JAXBContext} class provides the client's entry point to the
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    38
 * JAXB API. It provides an abstraction for managing the XML/Java binding
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    39
 * information necessary to implement the JAXB binding framework operations:
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    40
 * unmarshal, marshal and validate.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    41
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    42
 * <p>A client application normally obtains new instances of this class using
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    43
 * one of these two styles for newInstance methods, although there are other
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    44
 * specialized forms of the method available:
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    45
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    46
 * <ul>
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    47
 * <li>{@link #newInstance(String, ClassLoader) JAXBContext.newInstance( "com.acme.foo:com.acme.bar" )} <br>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    48
 * The JAXBContext instance is initialized from a list of colon
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    49
 * separated Java package names. Each java package contains
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    50
 * JAXB mapped classes, schema-derived classes and/or user annotated
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    51
 * classes. Additionally, the java package may contain JAXB package annotations
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    52
 * that must be processed. (see JLS, Section 7.4.1 "Named Packages").
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    53
 * </li>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    54
 * <li>{@link #newInstance(Class...) JAXBContext.newInstance( com.acme.foo.Foo.class )} <br>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    55
 * The JAXBContext instance is initialized with class(es)
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    56
 * passed as parameter(s) and classes that are statically reachable from
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    57
 * these class(es). See {@link #newInstance(Class...)} for details.
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
    58
 * </li>
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    59
 * </ul>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    60
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    61
 * <p><i>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    62
 * The following JAXB 1.0 requirement is only required for schema to
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    63
 * java interface/implementation binding. It does not apply to JAXB annotated
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
    64
 * classes. JAXB Providers must generate a {@code jaxb.properties} file in
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    65
 * each package containing schema derived classes.  The property file must
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
    66
 * contain a property named {@code javax.xml.bind.context.factory} whose
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
    67
 * value is the name of the class that implements the {@code createContext}
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    68
 * APIs.</i>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    69
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    70
 * <p><i>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    71
 * The class supplied by the provider does not have to be assignable to
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
    72
 * {@code javax.xml.bind.JAXBContext}, it simply has to provide a class that
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
    73
 * implements the {@code createContext} APIs.</i>
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    74
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    75
 * <p><i>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    76
 * In addition, the provider must call the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    77
 * {@link DatatypeConverter#setDatatypeConverter(DatatypeConverterInterface)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    78
 * DatatypeConverter.setDatatypeConverter} api prior to any client
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    79
 * invocations of the marshal and unmarshal methods.  This is necessary to
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    80
 * configure the datatype converter that will be used during these operations.</i>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    81
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    82
 * <a name="Unmarshalling"></a>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    83
 * <h3>Unmarshalling</h3>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    84
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    85
 * The {@link Unmarshaller} class provides the client application the ability
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    86
 * to convert XML data into a tree of Java content objects.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    87
 * The unmarshal method allows for
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    88
 * any global XML element declared in the schema to be unmarshalled as
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    89
 * the root of an instance document.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    90
 * Additionally, the unmarshal method allows for an unrecognized root element that
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    91
 * has  an xsi:type attribute's value that references a type definition declared in
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    92
 * the schema  to be unmarshalled as the root of an instance document.
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
    93
 * The {@code JAXBContext} object
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    94
 * allows the merging of global elements and type definitions across a set of schemas (listed
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
    95
 * in the {@code contextPath}). Since each schema in the schema set can belong
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    96
 * to distinct namespaces, the unification of schemas to an unmarshalling
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
    97
 * context must be namespace independent.  This means that a client
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    98
 * application is able to unmarshal XML documents that are instances of
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
    99
 * any of the schemas listed in the {@code contextPath}.  For example:
12009
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
 * <pre>
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   102
 *      JAXBContext jc = JAXBContext.newInstance( "com.acme.foo:com.acme.bar" );
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   103
 *      Unmarshaller u = jc.createUnmarshaller();
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   104
 *      FooObject fooObj = (FooObject)u.unmarshal( new File( "foo.xml" ) ); // ok
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   105
 *      BarObject barObj = (BarObject)u.unmarshal( new File( "bar.xml" ) ); // ok
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   106
 *      BazObject bazObj = (BazObject)u.unmarshal( new File( "baz.xml" ) ); // error, "com.acme.baz" not in contextPath
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   107
 * </pre>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   108
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   109
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   110
 * The client application may also generate Java content trees explicitly rather
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   111
 * than unmarshalling existing XML data.  For all JAXB-annotated value classes,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   112
 * an application can create content using constructors.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   113
 * For schema-derived interface/implementation classes and for the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   114
 * creation of elements that are not bound to a JAXB-annotated
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   115
 * class, an application needs to have access and knowledge about each of
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   116
 * the schema derived {@code ObjectFactory} classes that exist in each of
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   117
 * java packages contained in the {@code contextPath}.  For each schema
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   118
 * derived java class, there is a static factory method that produces objects
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   119
 * of that type.  For example,
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   120
 * assume that after compiling a schema, you have a package {@code com.acme.foo}
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   121
 * that contains a schema derived interface named {@code PurchaseOrder}.  In
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   122
 * order to create objects of that type, the client application would use the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   123
 * factory method like this:
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   124
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   125
 * <pre>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   126
 *       com.acme.foo.PurchaseOrder po =
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   127
 *           com.acme.foo.ObjectFactory.createPurchaseOrder();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   128
 * </pre>
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
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   131
 * Once the client application has an instance of the the schema derived object,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   132
 * it can use the mutator methods to set content on it.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   133
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   134
 * <p>
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   135
 * For more information on the generated {@code ObjectFactory} classes, see
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   136
 * Section 4.2 <i>Java Package</i> of the specification.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   137
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   138
 * <p>
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   139
 * <i>The provider must generate a class in each
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   140
 * package that contains all of the necessary object factory methods for that
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   141
 * package named ObjectFactory as well as the static
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   142
 * {@code newInstance( javaContentInterface )} method</i>
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   143
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   144
 * <h3>Marshalling</h3>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   145
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   146
 * The {@link Marshaller} class provides the client application the ability
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   147
 * to convert a Java content tree back into XML data.  There is no difference
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   148
 * between marshalling a content tree that is created manually using the factory
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   149
 * methods and marshalling a content tree that is the result an {@code unmarshal}
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   150
 * operation.  Clients can marshal a java content tree back to XML data
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   151
 * to a {@code java.io.OutputStream} or a {@code java.io.Writer}.  The
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   152
 * marshalling process can alternatively produce SAX2 event streams to a
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   153
 * registered {@code ContentHandler} or produce a DOM Node object.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   154
 * Client applications have control over the output encoding as well as
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   155
 * whether or not to marshal the XML data as a complete document or
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   156
 * as a fragment.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   157
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   158
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   159
 * Here is a simple example that unmarshals an XML document and then marshals
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   160
 * it back out:
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   161
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   162
 * <pre>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   163
 *        JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   164
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   165
 *        // unmarshal from foo.xml
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   166
 *        Unmarshaller u = jc.createUnmarshaller();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   167
 *        FooObject fooObj = (FooObject)u.unmarshal( new File( "foo.xml" ) );
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   168
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   169
 *        // marshal to System.out
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   170
 *        Marshaller m = jc.createMarshaller();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   171
 *        m.marshal( fooObj, System.out );
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   172
 * </pre>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   173
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   174
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   175
 * <h3>Validation</h3>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   176
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   177
 * Validation has been changed significantly since JAXB 1.0.  The {@link Validator}
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   178
 * class has been deprecated and made optional.  This means that you are advised
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   179
 * not to use this class and, in fact, it may not even be available depending on
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   180
 * your JAXB provider.  JAXB 1.0 client applications that rely on {@code Validator}
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   181
 * will still work properly when deployed with the JAXB 1.0 runtime system.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   182
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   183
 * In JAXB 2.0, the {@link Unmarshaller} has included convenince methods that expose
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   184
 * the JAXP 1.3 {@link javax.xml.validation} framework.  Please refer to the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   185
 * {@link Unmarshaller#setSchema(javax.xml.validation.Schema)} API for more
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   186
 * information.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   187
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   188
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   189
 * <h3>JAXB Runtime Binding Framework Compatibility</h3>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   190
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   191
 * The following JAXB 1.0 restriction only applies to binding schema to
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   192
 * interfaces/implementation classes.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   193
 * Since this binding does not require a common runtime system, a JAXB
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   194
 * client application must not attempt to mix runtime objects ({@code JAXBContext,
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   195
 * Marshaller}, etc. ) from different providers.  This does not
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   196
 * mean that the client application isn't portable, it simply means that a
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   197
 * client has to use a runtime system provided by the same provider that was
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   198
 * used to compile the schema.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   199
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   200
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   201
 * <h3>Discovery of JAXB implementation</h3>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   202
 * <p>
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   203
 * To create an instance of {@link JAXBContext}, one of {@code JAXBContext.newInstance(...)} methods is invoked. After
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   204
 * JAX-B implementation is discovered, call is delegated to appropriate provider's method {@code createContext(...)}
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   205
 * passing parameters from the original call.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   206
 * <p>
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   207
 * JAX-B implementation discovery happens each time {@code JAXBContext.newInstance} is invoked. If there is no user
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   208
 * specific configuration provided, default JAX-B provider must be returned.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   209
 * <p>
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   210
 * Implementation discovery consists of following steps:
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   211
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   212
 * <ol>
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   213
 *
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   214
 * <li>
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   215
 * Packages/classes explicitly passed in to the {@link #newInstance} method are processed in the order they are
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   216
 * specified, until {@code jaxb.properties} file is looked up in its package, by using the associated classloader &mdash;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   217
 * this is {@link Class#getClassLoader() the owner class loader} for a {@link Class} argument, and for a package
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   218
 * the specified {@link ClassLoader}.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   219
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   220
 * <p>
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   221
 * If such a resource is discovered, it is {@link Properties#load(InputStream) loaded} as a property file, and
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   222
 * the value of the {@link #JAXB_CONTEXT_FACTORY} key will be assumed to be the provider factory class. If no value
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   223
 * found, {@code "javax.xml.bind.context.factory"} is used as a key for backwards compatibility reasons. This class is
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   224
 * then loaded by the associated class loader discussed above.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   225
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   226
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   227
 * This phase of the look up allows some packages to force the use of a certain JAXB implementation.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   228
 * (For example, perhaps the schema compiler has generated some vendor extension in the code.)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   229
 *
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   230
 * <p>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   231
 * This configuration method is deprecated.
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   232
 *
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   233
 * <li>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   234
 * If the system property {@link #JAXB_CONTEXT_FACTORY} exists, then its value is assumed to be the provider
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   235
 * factory class. If no such property exists, properties {@code "javax.xml.bind.context.factory"} and
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   236
 * {@code "javax.xml.bind.JAXBContext"} are checked too (in this order), for backwards compatibility reasons. This phase
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   237
 * of the look up enables per-JVM override of the JAXB implementation.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   238
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   239
 * <li>
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   240
 * Provider of {@link javax.xml.bind.JAXBContextFactory} is loaded using the service-provider loading
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   241
 * facilities, defined by the {@link java.util.ServiceLoader} class, to attempt
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   242
 * to locate and load an implementation of the service using the {@linkplain
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   243
 * java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}: the service-provider loading facility
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   244
 * will use the {@linkplain java.lang.Thread#getContextClassLoader() current thread's context class loader}
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   245
 * to attempt to load the context factory. If the context class loader is null, the
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   246
 * {@linkplain ClassLoader#getSystemClassLoader() system class loader} will be used.
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   247
 * <br>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   248
 * In case of {@link java.util.ServiceConfigurationError service
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   249
 * configuration error} a {@link javax.xml.bind.JAXBException} will be thrown.
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   250
 *
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   251
 * <li>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   252
 * Look for resource {@code /META-INF/services/javax.xml.bind.JAXBContext} using provided class loader.
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   253
 * Methods without class loader parameter use {@code Thread.currentThread().getContextClassLoader()}.
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   254
 * If such a resource exists, its content is assumed to be the provider factory class.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   255
 *
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   256
 * This configuration method is deprecated.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   257
 *
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   258
 * <li>
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   259
 * Finally, if all the steps above fail, then the rest of the look up is unspecified. That said,
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   260
 * the recommended behavior is to simply look for some hard-coded platform default JAXB implementation.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   261
 * This phase of the look up is so that Java SE can have its own JAXB implementation as the last resort.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   262
 * </ol>
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   263
 *
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   264
 * <p>
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   265
 * Once the provider factory class is discovered, context creation is delegated to one of its
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   266
 * {@code createContext(...)} methods.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   267
 *
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   268
 * For backward compatibility reasons, there are two ways how to implement provider factory class:
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   269
 * <ol>
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   270
 *     <li>the class is implementation of {@link javax.xml.bind.JAXBContextFactory}. It must also implement no-arg
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   271
 *     constructor. If discovered in other step then 3, new instance using no-arg constructor is created first.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   272
 *     After that, appropriate instance method is invoked on this instance.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   273
 *     <li>the class is not implementation of interface above and then it is mandated to implement the following
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   274
 *     static method signatures:
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   275
 * <pre>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   276
 *
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   277
 * public static JAXBContext createContext(
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   278
 *                                      String contextPath,
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   279
 *                                      ClassLoader classLoader,
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   280
 *                                      Map&lt;String,Object&gt; properties ) throws JAXBException
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   281
 *
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   282
 * public static JAXBContext createContext(
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   283
 *                                      Class[] classes,
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   284
 *                                      Map&lt;String,Object&gt; properties ) throws JAXBException
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   285
 * </pre>
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   286
 *      In this scenario, appropriate static method is used instead of instance method. This approach is incompatible
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   287
 *      with {@link java.util.ServiceLoader} so it can't be used with step 3.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   288
 * </ol>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   289
 * <p>
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   290
 * There is no difference in behavior of given method {@code createContext(...)} regardless of whether it uses approach
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   291
 * 1 (JAXBContextFactory) or 2 (no interface, static methods).
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   292
 *
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   293
 * @apiNote
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   294
 * Service discovery method using resource {@code /META-INF/services/javax.xml.bind.JAXBContext} (described in step 4)
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   295
 * is supported only to allow backwards compatibility, it is strongly recommended to migrate to standard
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   296
 * {@link java.util.ServiceLoader} mechanism (described in step 3). The difference here is the resource name, which
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   297
 * doesn't match service's type name.
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   298
 * <p>
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   299
 * Also using providers implementing interface {@link JAXBContextFactory} is preferred over using ones defining
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   300
 * static methods, same as {@link JAXBContext#JAXB_CONTEXT_FACTORY} property is preferred over property
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   301
 * {@code "javax.xml.bind.context.factory"}
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   302
 *
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   303
 * @implNote
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   304
 * Within the last step, if Glassfish AS environment detected, its specific service loader is used to find factory class.
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   305
 *
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   306
 * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   307
 *             <li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   308
 *             <li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   309
 *
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   310
 * @see Marshaller
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   311
 * @see Unmarshaller
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   312
 * @see <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-7.html#jls-7.4.1">S 7.4.1 "Named Packages"
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   313
 *      in Java Language Specification</a>
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   314
 *
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 19645
diff changeset
   315
 * @since 1.6, JAXB 1.0
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   316
 */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   317
public abstract class JAXBContext {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   318
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   319
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   320
     * The name of the property that contains the name of the class capable
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   321
     * of creating new {@code JAXBContext} objects.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   322
     */
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   323
    public static final String JAXB_CONTEXT_FACTORY = "javax.xml.bind.JAXBContextFactory";
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   324
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   325
    protected JAXBContext() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   326
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   327
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   328
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   329
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   330
     * Create a new instance of a {@code JAXBContext} class.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   331
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   332
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   333
     * This is a convenience method to invoke the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   334
     * {@link #newInstance(String,ClassLoader)} method with
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   335
     * the context class loader of the current thread.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   336
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   337
     * @throws JAXBException if an error was encountered while creating the
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   338
     *                       {@code JAXBContext} such as
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   339
     * <ol>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   340
     *   <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   341
     *   <li>an ambiguity among global elements contained in the contextPath</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   342
     *   <li>failure to locate a value for the context factory provider property</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   343
     *   <li>mixing schema derived packages from different providers on the same contextPath</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   344
     *   <li>packages are not open to {@code java.xml.bind} module</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   345
     * </ol>
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   346
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   347
    public static JAXBContext newInstance( String contextPath )
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   348
            throws JAXBException {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   349
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   350
        //return newInstance( contextPath, JAXBContext.class.getClassLoader() );
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   351
        return newInstance( contextPath, getContextClassLoader());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   352
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   353
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   354
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   355
     * Create a new instance of a {@code JAXBContext} class.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   356
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   357
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   358
     * The client application must supply a context path which is a list of
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   359
     * colon (':', \u005Cu003A) separated java package names that contain
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   360
     * schema-derived classes and/or fully qualified JAXB-annotated classes.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   361
     * Schema-derived
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   362
     * code is registered with the JAXBContext by the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   363
     * ObjectFactory.class generated per package.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   364
     * Alternatively than being listed in the context path, programmer
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   365
     * annotated JAXB mapped classes can be listed in a
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   366
     * {@code jaxb.index} resource file, format described below.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   367
     * Note that a java package can contain both schema-derived classes and
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   368
     * user annotated JAXB classes. Additionally, the java package may
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   369
     * contain JAXB package annotations  that must be processed. (see JLS,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   370
     * Section 7.4.1 "Named Packages").
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   371
     * </p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   372
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   373
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   374
     * Every package listed on the contextPath must meet <b>one or both</b> of the
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   375
     * following conditions otherwise a {@code JAXBException} will be thrown:
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   376
     * </p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   377
     * <ol>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   378
     *   <li>it must contain ObjectFactory.class</li>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   379
     *   <li>it must contain jaxb.index</li>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   380
     * </ol>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   381
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   382
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   383
     * <b>Format for jaxb.index</b>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   384
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   385
     * The file contains a newline-separated list of class names.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   386
     * Space and tab characters, as well as blank
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   387
     * lines, are ignored. The comment character
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   388
     * is '#' (0x23); on each line all characters following the first comment
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   389
     * character are ignored. The file must be encoded in UTF-8. Classes that
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   390
     * are reachable, as defined in {@link #newInstance(Class...)}, from the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   391
     * listed classes are also registered with JAXBContext.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   392
     * <p>
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   393
     * Constraints on class name occuring in a {@code jaxb.index} file are:
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   394
     * <ul>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   395
     *   <li>Must not end with ".class".</li>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   396
     *   <li>Class names are resolved relative to package containing
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   397
     *       {@code jaxb.index} file. Only classes occuring directly in package
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   398
     *       containing {@code jaxb.index} file are allowed.</li>
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   399
     *   <li>Fully qualified class names are not allowed.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   400
     *       A qualified class name,relative to current package,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   401
     *       is only allowed to specify a nested or inner class.</li>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   402
     * </ul>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   403
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   404
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   405
     * To maintain compatibility with JAXB 1.0 schema to java
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   406
     * interface/implementation binding, enabled by schema customization
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   407
     * {@code <jaxb:globalBindings valueClass="false">},
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   408
     * the JAXB provider will ensure that each package on the context path
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   409
     * has a {@code jaxb.properties} file which contains a value for the
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   410
     * {@code javax.xml.bind.context.factory} property and that all values
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   411
     * resolve to the same provider.  This requirement does not apply to
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   412
     * JAXB annotated classes.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   413
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   414
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   415
     * If there are any global XML element name collisions across the various
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   416
     * packages listed on the {@code contextPath}, a {@code JAXBException}
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   417
     * will be thrown.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   418
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   419
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   420
     * Mixing generated interface/impl bindings from multiple JAXB Providers
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   421
     * in the same context path may result in a {@code JAXBException}
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   422
     * being thrown.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   423
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   424
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   425
     * The steps involved in discovering the JAXB implementation is discussed in the class javadoc.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   426
     *
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   427
     * @param contextPath
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   428
     *      List of java package names that contain schema
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   429
     *      derived class and/or java to schema (JAXB-annotated)
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   430
     *      mapped classes.
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   431
     *      Packages in {@code contextPath} that are in named modules must be
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   432
     *      {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   433
     * @param classLoader
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   434
     *      This class loader will be used to locate the implementation
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   435
     *      classes.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   436
     *
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   437
     * @return a new instance of a {@code JAXBContext}
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   438
     * @throws JAXBException if an error was encountered while creating the
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   439
     *                       {@code JAXBContext} such as
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   440
     * <ol>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   441
     *   <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   442
     *   <li>an ambiguity among global elements contained in the contextPath</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   443
     *   <li>failure to locate a value for the context factory provider property</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   444
     *   <li>mixing schema derived packages from different providers on the same contextPath</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   445
     *   <li>packages are not open to {@code java.xml.bind} module</li>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   446
     * </ol>
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   447
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   448
    public static JAXBContext newInstance( String contextPath, ClassLoader classLoader ) throws JAXBException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   449
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   450
        return newInstance(contextPath,classLoader,Collections.<String,Object>emptyMap());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   451
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   452
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   453
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   454
     * Create a new instance of a {@code JAXBContext} class.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   455
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   456
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   457
     * This is mostly the same as {@link JAXBContext#newInstance(String, ClassLoader)},
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   458
     * but this version allows you to pass in provider-specific properties to configure
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   459
     * the instantiation of {@link JAXBContext}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   460
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   461
     * <p>
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   462
     * The interpretation of properties is up to implementations. Implementations must
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   463
     * throw {@code JAXBException} if it finds properties that it doesn't understand.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   464
     *
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   465
     * @param contextPath
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   466
     *      List of java package names that contain schema
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   467
     *      derived class and/or java to schema (JAXB-annotated)
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   468
     *      mapped classes.
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   469
     *      Packages in {@code contextPath} that are in named modules must be
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   470
     *      {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   471
     * @param classLoader
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   472
     *      This class loader will be used to locate the implementation classes.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   473
     * @param properties
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   474
     *      provider-specific properties. Can be null, which means the same thing as passing
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   475
     *      in an empty map.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   476
     *
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   477
     * @return a new instance of a {@code JAXBContext}
42124
640a383428fb 8164479: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT)
aefimov
parents: 36033
diff changeset
   478
     * @throws JAXBException if an error was encountered while creating the
640a383428fb 8164479: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT)
aefimov
parents: 36033
diff changeset
   479
     *                       {@code JAXBContext} such as
36033
f50f6572da23 8149923: invalid javadoc in javax.xml.bind.JAXBContext (introduced by 8138699)
mkos
parents: 35414
diff changeset
   480
     * <ol>
f50f6572da23 8149923: invalid javadoc in javax.xml.bind.JAXBContext (introduced by 8138699)
mkos
parents: 35414
diff changeset
   481
     *   <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
f50f6572da23 8149923: invalid javadoc in javax.xml.bind.JAXBContext (introduced by 8138699)
mkos
parents: 35414
diff changeset
   482
     *   <li>an ambiguity among global elements contained in the contextPath</li>
f50f6572da23 8149923: invalid javadoc in javax.xml.bind.JAXBContext (introduced by 8138699)
mkos
parents: 35414
diff changeset
   483
     *   <li>failure to locate a value for the context factory provider property</li>
f50f6572da23 8149923: invalid javadoc in javax.xml.bind.JAXBContext (introduced by 8138699)
mkos
parents: 35414
diff changeset
   484
     *   <li>mixing schema derived packages from different providers on the same contextPath</li>
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   485
     *   <li>packages are not open to {@code java.xml.bind} module</li>
36033
f50f6572da23 8149923: invalid javadoc in javax.xml.bind.JAXBContext (introduced by 8138699)
mkos
parents: 35414
diff changeset
   486
     * </ol>
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 19645
diff changeset
   487
     * @since 1.6, JAXB 2.0
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   488
     */
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   489
    public static JAXBContext newInstance( String contextPath,
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   490
                                           ClassLoader classLoader,
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   491
                                           Map<String,?>  properties  ) throws JAXBException {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   492
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   493
        return ContextFinder.find(
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   494
                        /* The default property name according to the JAXB spec */
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   495
                JAXB_CONTEXT_FACTORY,
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   496
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   497
                        /* the context path supplied by the client app */
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   498
                contextPath,
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   499
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   500
                        /* class loader to be used */
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   501
                classLoader,
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   502
                properties );
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   503
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   504
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   505
// TODO: resurrect this once we introduce external annotations
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   506
//    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   507
//     * Create a new instance of a {@code JAXBContext} class.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   508
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   509
//     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   510
//     * The client application must supply a list of classes that the new
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   511
//     * context object needs to recognize.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   512
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   513
//     * Not only the new context will recognize all the classes specified,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   514
//     * but it will also recognize any classes that are directly/indirectly
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   515
//     * referenced statically from the specified classes.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   516
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   517
//     * For example, in the following Java code, if you do
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   518
//     * {@code newInstance(Foo.class)}, the newly created {@link JAXBContext}
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   519
//     * will recognize both {@code Foo} and {@code Bar}, but not {@code Zot}:
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   520
//     * <pre>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   521
//     * class Foo {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   522
//     *      Bar b;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   523
//     * }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   524
//     * class Bar { int x; }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   525
//     * class Zot extends Bar { int y; }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   526
//     * </pre>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   527
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   528
//     * Therefore, a typical client application only needs to specify the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   529
//     * top-level classes, but it needs to be careful.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   530
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   531
//     * TODO: if we are to define other mechanisms, refer to them.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   532
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   533
//     * @param externalBindings
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   534
//     *      list of external binding files. Can be null or empty if none is used.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   535
//     *      when specified, those files determine how the classes are bound.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   536
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   537
//     * @param classesToBeBound
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   538
//     *      list of java classes to be recognized by the new {@link JAXBContext}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   539
//     *      Can be empty, in which case a {@link JAXBContext} that only knows about
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   540
//     *      spec-defined classes will be returned.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   541
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   542
//     * @return
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   543
//     *      A new instance of a {@code JAXBContext}.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   544
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   545
//     * @throws JAXBException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   546
//     *      if an error was encountered while creating the
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   547
//     *      {@code JAXBContext}, such as (but not limited to):
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   548
//     * <ol>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   549
//     *  <li>No JAXB implementation was discovered
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   550
//     *  <li>Classes use JAXB annotations incorrectly
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   551
//     *  <li>Classes have colliding annotations (i.e., two classes with the same type name)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   552
//     *  <li>Specified external bindings are incorrect
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   553
//     *  <li>The JAXB implementation was unable to locate
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   554
//     *      provider-specific out-of-band information (such as additional
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   555
//     *      files generated at the development time.)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   556
//     * </ol>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   557
//     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   558
//     * @throws IllegalArgumentException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   559
//     *      if the parameter contains {@code null} (i.e., {@code newInstance(null);})
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   560
//     *
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 19645
diff changeset
   561
//     * @since JAXB 2.0
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   562
//     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   563
//    public static JAXBContext newInstance( Source[] externalBindings, Class... classesToBeBound )
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   564
//        throws JAXBException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   565
//
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   566
//        // empty class list is not an error, because the context will still include
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   567
//        // spec-specified classes like String and Integer.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   568
//        // if(classesToBeBound.length==0)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   569
//        //    throw new IllegalArgumentException();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   570
//
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   571
//        // but it is an error to have nulls in it.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   572
//        for( int i=classesToBeBound.length-1; i>=0; i-- )
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   573
//            if(classesToBeBound[i]==null)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   574
//                throw new IllegalArgumentException();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   575
//
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   576
//        return ContextFinder.find(externalBindings,classesToBeBound);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   577
//    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   578
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   579
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   580
     * Create a new instance of a {@code JAXBContext} class.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   581
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   582
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   583
     * The client application must supply a list of classes that the new
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   584
     * context object needs to recognize.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   585
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   586
     * Not only the new context will recognize all the classes specified,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   587
     * but it will also recognize any classes that are directly/indirectly
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   588
     * referenced statically from the specified classes. Subclasses of
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   589
     * referenced classes nor {@code @XmlTransient} referenced classes
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   590
     * are not registered with JAXBContext.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   591
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   592
     * For example, in the following Java code, if you do
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   593
     * {@code newInstance(Foo.class)}, the newly created {@link JAXBContext}
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   594
     * will recognize both {@code Foo} and {@code Bar}, but not {@code Zot} or {@code FooBar}:
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   595
     * <pre>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   596
     * class Foo {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   597
     *      &#64;XmlTransient FooBar c;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   598
     *      Bar b;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   599
     * }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   600
     * class Bar { int x; }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   601
     * class Zot extends Bar { int y; }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   602
     * class FooBar { }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   603
     * </pre>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   604
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   605
     * Therefore, a typical client application only needs to specify the
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   606
     * top-level classes, but it needs to be careful.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   607
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   608
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   609
     * Note that for each java package registered with JAXBContext,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   610
     * when the optional package annotations exist, they must be processed.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   611
     * (see JLS, Section 7.4.1 "Named Packages").
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   612
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   613
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   614
     * The steps involved in discovering the JAXB implementation is discussed in the class javadoc.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   615
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   616
     * @param classesToBeBound
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   617
     *      List of java classes to be recognized by the new {@link JAXBContext}.
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   618
     *      Classes in {@code classesToBeBound} that are in named modules must be in a package
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   619
     *      that is {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   620
     *      Can be empty, in which case a {@link JAXBContext} that only knows about
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   621
     *      spec-defined classes will be returned.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   622
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   623
     * @return
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   624
     *      A new instance of a {@code JAXBContext}.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   625
     *
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   626
     * @throws JAXBException
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   627
     *      if an error was encountered while creating the
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   628
     *      {@code JAXBContext}, such as (but not limited to):
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   629
     * <ol>
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   630
     *  <li>No JAXB implementation was discovered
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   631
     *  <li>Classes use JAXB annotations incorrectly
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   632
     *  <li>Classes have colliding annotations (i.e., two classes with the same type name)
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   633
     *  <li>The JAXB implementation was unable to locate
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   634
     *      provider-specific out-of-band information (such as additional
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   635
     *      files generated at the development time.)
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   636
     *  <li>{@code classesToBeBound} are not open to {@code java.xml.bind} module
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   637
     * </ol>
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   638
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   639
     * @throws IllegalArgumentException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   640
     *      if the parameter contains {@code null} (i.e., {@code newInstance(null);})
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   641
     *
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 19645
diff changeset
   642
     * @since 1.6, JAXB 2.0
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   643
     */
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   644
    public static JAXBContext newInstance( Class<?> ... classesToBeBound )
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   645
            throws JAXBException {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   646
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   647
        return newInstance(classesToBeBound,Collections.<String,Object>emptyMap());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   648
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   649
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   650
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   651
     * Create a new instance of a {@code JAXBContext} class.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   652
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   653
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   654
     * An overloading of {@link JAXBContext#newInstance(Class...)}
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   655
     * to configure 'properties' for this instantiation of {@link JAXBContext}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   656
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   657
     * <p>
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   658
     * The interpretation of properties is up to implementations. Implementations must
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   659
     * throw {@code JAXBException} if it finds properties that it doesn't understand.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   660
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   661
     * @param classesToBeBound
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   662
     *      List of java classes to be recognized by the new {@link JAXBContext}.
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   663
     *      Classes in {@code classesToBeBound} that are in named modules must be in a package
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   664
     *      that is {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   665
     *      Can be empty, in which case a {@link JAXBContext} that only knows about
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   666
     *      spec-defined classes will be returned.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   667
     * @param properties
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   668
     *      provider-specific properties. Can be null, which means the same thing as passing
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   669
     *      in an empty map.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   670
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   671
     * @return
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   672
     *      A new instance of a {@code JAXBContext}.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   673
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   674
     * @throws JAXBException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   675
     *      if an error was encountered while creating the
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   676
     *      {@code JAXBContext}, such as (but not limited to):
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   677
     * <ol>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   678
     *  <li>No JAXB implementation was discovered
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   679
     *  <li>Classes use JAXB annotations incorrectly
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   680
     *  <li>Classes have colliding annotations (i.e., two classes with the same type name)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   681
     *  <li>The JAXB implementation was unable to locate
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   682
     *      provider-specific out-of-band information (such as additional
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   683
     *      files generated at the development time.)
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   684
     *  <li>{@code classesToBeBound} are not open to {@code java.xml.bind} module
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   685
     * </ol>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   686
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   687
     * @throws IllegalArgumentException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   688
     *      if the parameter contains {@code null} (i.e., {@code newInstance(null,someMap);})
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   689
     *
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 19645
diff changeset
   690
     * @since 1.6, JAXB 2.0
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   691
     */
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   692
    public static JAXBContext newInstance( Class<?>[] classesToBeBound, Map<String,?> properties )
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   693
            throws JAXBException {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   694
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   695
        if (classesToBeBound == null) {
35414
59fc48a1a885 8138699: Improving JAX-B API javadoc
mkos
parents: 31501
diff changeset
   696
            throw new IllegalArgumentException();
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   697
        }
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   698
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   699
        // but it is an error to have nulls in it.
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   700
        for (int i = classesToBeBound.length - 1; i >= 0; i--) {
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   701
            if (classesToBeBound[i] == null) {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   702
                throw new IllegalArgumentException();
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   703
            }
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   704
        }
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   705
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   706
        return ContextFinder.find(classesToBeBound,properties);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   707
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   708
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   709
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   710
     * Create an {@code Unmarshaller} object that can be used to convert XML
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   711
     * data into a java content tree.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   712
     *
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   713
     * @return an {@code Unmarshaller} object
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   714
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   715
     * @throws JAXBException if an error was encountered while creating the
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   716
     *                       {@code Unmarshaller} object
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   717
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   718
    public abstract Unmarshaller createUnmarshaller() throws JAXBException;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   719
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   720
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   721
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   722
     * Create a {@code Marshaller} object that can be used to convert a
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   723
     * java content tree into XML data.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   724
     *
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   725
     * @return a {@code Marshaller} object
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   726
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   727
     * @throws JAXBException if an error was encountered while creating the
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   728
     *                       {@code Marshaller} object
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   729
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   730
    public abstract Marshaller createMarshaller() throws JAXBException;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   731
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   732
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   733
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   734
     * {@link Validator} has been made optional and deprecated in JAXB 2.0.  Please
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   735
     * refer to the javadoc for {@link Validator} for more detail.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   736
     * <p>
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   737
     * Create a {@code Validator} object that can be used to validate a
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   738
     * java content tree against its source schema.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   739
     *
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   740
     * @return a {@code Validator} object
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   741
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   742
     * @throws JAXBException if an error was encountered while creating the
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   743
     *                       {@code Validator} object
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   744
     * @deprecated since JAXB2.0
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   745
     */
45678
65fdff10664d 8176508: Update JAX-WS RI integration to latest version
aefimov
parents: 42124
diff changeset
   746
    @Deprecated
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   747
    public abstract Validator createValidator() throws JAXBException;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   748
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   749
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   750
     * Creates a {@code Binder} object that can be used for
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   751
     * associative/in-place unmarshalling/marshalling.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   752
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   753
     * @param domType select the DOM API to use by passing in its DOM Node class.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   754
     *
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   755
     * @return always a new valid {@code Binder} object.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   756
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   757
     * @throws UnsupportedOperationException
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   758
     *      if DOM API corresponding to {@code domType} is not supported by
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   759
     *      the implementation.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   760
     *
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 19645
diff changeset
   761
     * @since 1.6, JAXB 2.0
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   762
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   763
    public <T> Binder<T> createBinder(Class<T> domType) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   764
        // to make JAXB 1.0 implementations work, this method must not be
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   765
        // abstract
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   766
        throw new UnsupportedOperationException();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   767
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   768
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   769
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   770
     * Creates a {@code Binder} for W3C DOM.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   771
     *
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   772
     * @return always a new valid {@code Binder} object.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   773
     *
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 19645
diff changeset
   774
     * @since 1.6, JAXB 2.0
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   775
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   776
    public Binder<Node> createBinder() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   777
        return createBinder(Node.class);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   778
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   779
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   780
    /**
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   781
     * Creates a {@code JAXBIntrospector} object that can be used to
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   782
     * introspect JAXB objects.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   783
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   784
     * @return
31501
1b48499c9e1c 8130247: fix some new tidy warnings from jaxws and CORBA
avstepan
parents: 31109
diff changeset
   785
     *      always return a non-null valid {@code JAXBIntrospector} object.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   786
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   787
     * @throws UnsupportedOperationException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   788
     *      Calling this method on JAXB 1.0 implementations will throw
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   789
     *      an UnsupportedOperationException.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   790
     *
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 19645
diff changeset
   791
     * @since 1.6, JAXB 2.0
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   792
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   793
    public JAXBIntrospector createJAXBIntrospector() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   794
        // to make JAXB 1.0 implementations work, this method must not be
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   795
        // abstract
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   796
        throw new UnsupportedOperationException();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   797
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   798
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   799
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   800
     * Generates the schema documents for this context.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   801
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   802
     * @param outputResolver
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   803
     *      this object controls the output to which schemas
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   804
     *      will be sent.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   805
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   806
     * @throws IOException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   807
     *      if {@link SchemaOutputResolver} throws an {@link IOException}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   808
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   809
     * @throws UnsupportedOperationException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   810
     *      Calling this method on JAXB 1.0 implementations will throw
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   811
     *      an UnsupportedOperationException.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   812
     *
25840
c2002453eec3 8047724: @since tag cleanup in jaxws
henryjen
parents: 19645
diff changeset
   813
     * @since 1.6, JAXB 2.0
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   814
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   815
    public void generateSchema(SchemaOutputResolver outputResolver) throws IOException  {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   816
        // to make JAXB 1.0 implementations work, this method must not be
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   817
        // abstract
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   818
        throw new UnsupportedOperationException();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   819
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   820
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   821
    private static ClassLoader getContextClassLoader() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   822
        if (System.getSecurityManager() == null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   823
            return Thread.currentThread().getContextClassLoader();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   824
        } else {
31109
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   825
            return java.security.AccessController.doPrivileged(
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   826
                    new java.security.PrivilegedAction<ClassLoader>() {
a542f8dcbbf8 8072839: JAX-B Plugability Layer: using java.util.ServiceLoader
mkos
parents: 29839
diff changeset
   827
                        public ClassLoader run() {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   828
                            return Thread.currentThread().getContextClassLoader();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   829
                        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   830
                    });
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   831
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   832
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   833
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   834
}