Java XML JAXB Context createJaxbContextFor(Object obj, Class[] classes)

Here you can find the source of createJaxbContextFor(Object obj, Class[] classes)

Description

create Jaxb Context For

License

Open Source License

Declaration

private static JAXBContext createJaxbContextFor(Object obj, Class<?>[] classes) throws JAXBException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;

public class Main {
    private static JAXBContext createJaxbContextFor(Object obj, Class<?>[] classes) throws JAXBException {
        Set<Class<?>> classSet = new HashSet<>();
        classSet.addAll(Arrays.asList(classes));
        classSet.add(obj.getClass());/*from  w w  w  .  j  av  a 2s . co  m*/
        return JAXBContext.newInstance(classSet.toArray(new Class<?>[0]));
    }
}

Related

  1. clearContextCache()
  2. createContext(final Class bind)
  3. createRIContext(Class clss[], String defaultNS)
  4. fromXML(JAXBContext context, String requestXML)
  5. generateTemporarySchemaFile(JAXBContext context)
  6. getCachedContext(String pkg)