1 /*
   2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.xml.bind;
  27 
  28 import java.util.Map;
  29 
  30 /**
  31  * <p>Factory that creates new <code>JAXBContext</code> instances.
  32  *
  33  * JAXBContextFactory can be located using {@link java.util.ServiceLoader#load(Class)}
  34  *
  35  * @since 9, JAXB 2.3
  36  */
  37 public interface JAXBContextFactory {
  38 
  39     /**
  40      * <p>
  41      * Create a new instance of a {@code JAXBContext} class.
  42      *
  43      * <p>
  44      * For semantics see {@link javax.xml.bind.JAXBContext#newInstance(Class[], java.util.Map)}
  45      *
  46      * @param classesToBeBound
  47      *      list of java classes to be recognized by the new {@link JAXBContext}.
  48      *      Can be empty, in which case a {@link JAXBContext} that only knows about
  49      *      spec-defined classes will be returned.
  50      * @param properties
  51      *      provider-specific properties. Can be null, which means the same thing as passing
  52      *      in an empty map.
  53      *
  54      * @return
  55      *      A new instance of a {@code JAXBContext}.
  56      *
  57      * @throws JAXBException
  58      *      if an error was encountered while creating the
  59      *      {@code JAXBContext}. See {@link JAXBContext#newInstance(Class[], Map)} for details.
  60      *
  61      * @throws IllegalArgumentException
  62      *      if the parameter contains {@code null} (i.e., {@code newInstance(null,someMap);})
  63      *
  64      * @since 9, JAXB 2.3
  65      */
  66     JAXBContext createContext(Class<?>[] classesToBeBound,
  67                               Map<String, ?> properties ) throws JAXBException;
  68 
  69     /**
  70      * <p>
  71      * Create a new instance of a {@code JAXBContext} class.
  72      *
  73      * <p>
  74      * For semantics see {@link javax.xml.bind.JAXBContext#newInstance(String, ClassLoader, java.util.Map)}
  75      *
  76      * <p>
  77      * The interpretation of properties is up to implementations. Implementations must
  78      * throw {@code JAXBException} if it finds properties that it doesn't understand.
  79      *
  80      * @param contextPath list of java package names that contain schema derived classes
  81      * @param classLoader
  82      *      This class loader will be used to locate the implementation classes.
  83      * @param properties
  84      *      provider-specific properties. Can be null, which means the same thing as passing
  85      *      in an empty map.
  86      *
  87      * @return a new instance of a {@code JAXBContext}
  88      * @throws JAXBException if an error was encountered while creating the
  89      *      {@code JAXBContext}. See {@link JAXBContext#newInstance(String, ClassLoader, Map)} for details.
  90      *
  91      * @since 9, JAXB 2.3
  92      */
  93     JAXBContext createContext(String contextPath,
  94                               ClassLoader classLoader,
  95                               Map<String, ?> properties ) throws JAXBException;
  96 
  97 }