use of org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceRuntimeXMLProject in project eclipselink by eclipse-ee4j.
the class XMLProjectReader method readObjectPersistenceRuntimeFormat.
/**
* Read a project in the format of an ObjectPersistenceRuntimeXMLProject.
* This could include a TopLink 11.1.1 project or a TopLink 10.1.3 project
*/
public static Project readObjectPersistenceRuntimeFormat(Document document, ClassLoader classLoader, Project opmProject) {
XMLLogin xmlLogin = new XMLLogin();
xmlLogin.setDatasourcePlatform(new org.eclipse.persistence.oxm.platform.DOMPlatform());
opmProject.setDatasourceLogin(xmlLogin);
// Create the OPM project.
if (classLoader != null) {
xmlLogin.getDatasourcePlatform().getConversionManager().setLoader(classLoader);
}
// Marshal OPM format.
XMLContext context = new XMLContext(opmProject);
context.getSession(Project.class).getEventManager().addListener(new MissingDescriptorListener());
XMLUnmarshaller unmarshaller = context.createUnmarshaller();
Project project = (Project) unmarshaller.unmarshal(document);
// Set the project's class loader.
if ((classLoader != null) && (project.getDatasourceLogin() != null)) {
project.getDatasourceLogin().getDatasourcePlatform().getConversionManager().setLoader(classLoader);
}
return project;
}
Aggregations