Search in sources :

Example 1 with ObjectPersistenceRuntimeXMLProject

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;
}
Also used : EclipseLinkObjectPersistenceRuntimeXMLProject(org.eclipse.persistence.internal.sessions.factories.EclipseLinkObjectPersistenceRuntimeXMLProject) Project(org.eclipse.persistence.sessions.Project) ObjectPersistenceRuntimeXMLProject(org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceRuntimeXMLProject) XMLContext(org.eclipse.persistence.oxm.XMLContext) XMLLogin(org.eclipse.persistence.oxm.XMLLogin) MissingDescriptorListener(org.eclipse.persistence.internal.sessions.factories.MissingDescriptorListener) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller)

Aggregations

EclipseLinkObjectPersistenceRuntimeXMLProject (org.eclipse.persistence.internal.sessions.factories.EclipseLinkObjectPersistenceRuntimeXMLProject)1 MissingDescriptorListener (org.eclipse.persistence.internal.sessions.factories.MissingDescriptorListener)1 ObjectPersistenceRuntimeXMLProject (org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceRuntimeXMLProject)1 XMLContext (org.eclipse.persistence.oxm.XMLContext)1 XMLLogin (org.eclipse.persistence.oxm.XMLLogin)1 XMLUnmarshaller (org.eclipse.persistence.oxm.XMLUnmarshaller)1 Project (org.eclipse.persistence.sessions.Project)1