*/
protected DatabaseSession loadDatabaseSession(
String configLocation, String sessionName, ClassLoader sessionClassLoader)
throws TopLinkException {
SessionManager manager = getSessionManager();
// Try to find TopLink 10.1.3 XMLSessionConfigLoader.
Method getSessionMethod = null;
Object loader = null;
try {
Class loaderClass = SessionManager.class.getClassLoader().loadClass(
"oracle.toplink.tools.sessionconfiguration.XMLSessionConfigLoader");
getSessionMethod = SessionManager.class.getMethod("getSession",
new Class[] {loaderClass, String.class, ClassLoader.class, boolean.class, boolean.class, boolean.class});
if (logger.isDebugEnabled()) {
logger.debug("Using TopLink 10.1.3 XMLSessionConfigLoader");
}
Constructor ctor = loaderClass.getConstructor(new Class[] {String.class});
loader = ctor.newInstance(new Object[] {configLocation});
}
catch (Exception ex) {
// TopLink 10.1.3 XMLSessionConfigLoader not found ->
// fall back to TopLink 9.0.4 XMLLoader.
if (logger.isDebugEnabled()) {
logger.debug("Using TopLink 9.0.4 XMLLoader");
}
XMLLoader xmlLoader = new XMLLoader(configLocation);
return (DatabaseSession) manager.getSession(xmlLoader, sessionName, sessionClassLoader, false, false);
}
// TopLink 10.1.3 XMLSessionConfigLoader found -> create loader instance
// through reflection and fetch specified Session from SessionManager.
// This invocation will check if the ClassLoader passed in is the same