Java XML JAXB Context getContext()

Here you can find the source of getContext()

Description

Returns the JAXBContext for this format.

License

Apache License

Exception

Parameter Description
JAXBException if a problem with JAXB occured

Return

context

Declaration

public synchronized static JAXBContext getContext() throws JAXBException 

Method Source Code

//package com.java2s;
/*/*from  w  w  w  .j av  a  2s .c o  m*/
 * Copyright 2015-2016 OpenEstate.org.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;

public class Main {
    private static JAXBContext JAXB = null;
    /**
     * the package, where generated JAXB classes are located
     */
    public final static String PACKAGE = "org.openestate.io.casa_it.xml";

    /**
     * Returns the {@link JAXBContext} for this format.
     *
     * @return
     * context
     *
     * @throws JAXBException
     * if a problem with JAXB occured
     */
    public synchronized static JAXBContext getContext() throws JAXBException {
        if (JAXB == null)
            initContext(Thread.currentThread().getContextClassLoader());
        return JAXB;
    }

    /**
     * Intializes the {@link JAXBContext} for this format.
     *
     * @param classloader
     * the classloader to load the generated JAXB classes with
     *
     * @throws JAXBException
     * if a problem with JAXB occured
     */
    public synchronized static void initContext(ClassLoader classloader) throws JAXBException {
        JAXB = JAXBContext.newInstance(PACKAGE, classloader);
    }
}

Related

  1. createRIContext(Class clss[], String defaultNS)
  2. fromXML(JAXBContext context, String requestXML)
  3. generateTemporarySchemaFile(JAXBContext context)
  4. getCachedContext(String pkg)
  5. getContext()
  6. getContext()
  7. getContext()
  8. getContext(Class c)
  9. getContext(Class clazz)