storeXMLDescriptorsByQName(session);
}
private DatabaseSession buildSession(String sessionName, ClassLoader classLoader, XMLSessionConfigLoader sessionLoader) throws XMLMarshalException {
DatabaseSession dbSession;
if (classLoader != null) {
dbSession = (DatabaseSession) SessionManager.getManager().getSession(sessionLoader, sessionName, classLoader, false, true);
} else {
dbSession = (DatabaseSession) SessionManager.getManager().getSession(sessionLoader, sessionName, PrivilegedAccessHelper.privilegedGetClassLoaderForClass(this.getClass()), false, false, false);
}
if ((dbSession.getDatasourceLogin() == null) || !(dbSession.getDatasourceLogin().getDatasourcePlatform() instanceof XMLPlatform)) {
XMLPlatform platform = new SAXPlatform();
dbSession.setLogin(new XMLLogin(platform));
}
DatabaseSession session = dbSession.getProject().createDatabaseSession();
if (dbSession.getEventManager().hasListeners()) {
List listeners = dbSession.getEventManager().getListeners();
int listenersSize = listeners.size();
for (int x = 0; x < listenersSize; x++) {
session.getEventManager().addListener((SessionEventListener) listeners.get(x));
}
}
session.setExceptionHandler(dbSession.getExceptionHandler());
session.setLogLevel(SessionLog.OFF);
setupDocumentPreservationPolicy(session);
session.login();
return session;
}