1 /* |
1 /* |
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
51 * JAXB mapped classes, schema-derived classes and/or user annotated |
51 * JAXB mapped classes, schema-derived classes and/or user annotated |
52 * classes. Additionally, the java package may contain JAXB package annotations |
52 * classes. Additionally, the java package may contain JAXB package annotations |
53 * that must be processed. (see JLS, Section 7.4.1 "Named Packages"). |
53 * that must be processed. (see JLS, Section 7.4.1 "Named Packages"). |
54 * </li> |
54 * </li> |
55 * <li>{@link #newInstance(Class...) JAXBContext.newInstance( com.acme.foo.Foo.class )} <br/> |
55 * <li>{@link #newInstance(Class...) JAXBContext.newInstance( com.acme.foo.Foo.class )} <br/> |
56 * The JAXBContext instance is intialized with class(es) |
56 * The JAXBContext instance is initialized with class(es) |
57 * passed as parameter(s) and classes that are statically reachable from |
57 * passed as parameter(s) and classes that are statically reachable from |
58 * these class(es). See {@link #newInstance(Class...)} for details. |
58 * these class(es). See {@link #newInstance(Class...)} for details. |
59 * </li> |
59 * </li> |
60 * </ul> |
60 * </ul> |
61 * |
61 * |
216 * <ol> |
216 * <ol> |
217 * <li> |
217 * <li> |
218 * For each package/class explicitly passed in to the {@link #newInstance} method, in the order they are specified, |
218 * For each package/class explicitly passed in to the {@link #newInstance} method, in the order they are specified, |
219 * <tt>jaxb.properties</tt> file is looked up in its package, by using the associated classloader — |
219 * <tt>jaxb.properties</tt> file is looked up in its package, by using the associated classloader — |
220 * this is {@link Class#getClassLoader() the owner class loader} for a {@link Class} argument, and for a package |
220 * this is {@link Class#getClassLoader() the owner class loader} for a {@link Class} argument, and for a package |
221 * the speified {@link ClassLoader}. |
221 * the specified {@link ClassLoader}. |
222 * |
222 * |
223 * <p> |
223 * <p> |
224 * If such a file is discovered, it is {@link Properties#load(InputStream) loaded} as a property file, and |
224 * If such a file is discovered, it is {@link Properties#load(InputStream) loaded} as a property file, and |
225 * the value of the {@link #JAXB_CONTEXT_FACTORY} key will be assumed to be the provider factory class. |
225 * the value of the {@link #JAXB_CONTEXT_FACTORY} key will be assumed to be the provider factory class. |
226 * This class is then loaded by the associated classloader discussed above. |
226 * This class is then loaded by the associated classloader discussed above. |
625 * @since JAXB2.0 |
625 * @since JAXB2.0 |
626 */ |
626 */ |
627 public static JAXBContext newInstance( Class[] classesToBeBound, Map<String,?> properties ) |
627 public static JAXBContext newInstance( Class[] classesToBeBound, Map<String,?> properties ) |
628 throws JAXBException { |
628 throws JAXBException { |
629 |
629 |
630 if (classesToBeBound == null) throw new IllegalArgumentException(); |
630 if (classesToBeBound == null) { |
|
631 throw new IllegalArgumentException(); |
|
632 } |
631 |
633 |
632 // but it is an error to have nulls in it. |
634 // but it is an error to have nulls in it. |
633 for( int i=classesToBeBound.length-1; i>=0; i-- ) |
635 for (int i = classesToBeBound.length - 1; i >= 0; i--) { |
634 if(classesToBeBound[i]==null) |
636 if (classesToBeBound[i] == null) { |
635 throw new IllegalArgumentException(); |
637 throw new IllegalArgumentException(); |
|
638 } |
|
639 } |
636 |
640 |
637 return ContextFinder.find(classesToBeBound,properties); |
641 return ContextFinder.find(classesToBeBound,properties); |
638 } |
642 } |
639 |
643 |
640 /** |
644 /** |