private static javax.xml.bind.JAXBContext createContext(Generator generator, java.util.Map properties, ClassLoader classLoader, JaxbClassLoader loader, Type[] typesToBeBound) throws Exception {
javax.xml.bind.JAXBContext jaxbContext = null;
XMLContext xmlContext = null;
Project proj = generator.generateProject();
ConversionManager conversionManager = null;
if (classLoader != null) {
conversionManager = new ConversionManager();
conversionManager.setLoader(loader);
} else {
conversionManager = ConversionManager.getDefaultManager();
}
proj.convertClassNamesToClasses(conversionManager.getLoader());
// need to make sure that the java class is set properly on each
// descriptor when using java classname - req'd for JOT api implementation
for (Iterator<ClassDescriptor> descriptorIt = proj.getOrderedDescriptors().iterator(); descriptorIt.hasNext();) {
ClassDescriptor descriptor = descriptorIt.next();
if (descriptor.getJavaClass() == null) {
descriptor.setJavaClass(conversionManager.convertClassNameToClass(descriptor.getJavaClassName()));
}
}
// disable instantiation policy validation during descriptor initialization
SessionEventListener eventListener = new SessionEventListener();
eventListener.setShouldValidateInstantiationPolicy(false);
XMLPlatform platform = new SAXPlatform();
platform.getConversionManager().setLoader(loader);
XMLLogin login = new XMLLogin(platform);
login.setEqualNamespaceResolvers(false);
proj.setLogin(login);
xmlContext = new XMLContext(proj, loader, eventListener);
jaxbContext = new org.eclipse.persistence.jaxb.JAXBContext(xmlContext, generator, typesToBeBound);
return jaxbContext;
}