use of org.apache.cayenne.modeler.Application in project cayenne by apache.
the class DBConnectionInfo method makeAdapter.
/**
* Creates a DbAdapter based on configured values.
*/
public DbAdapter makeAdapter(ClassLoadingService classLoader) throws Exception {
String adapterClassName = getDbAdapter();
Application appInstance = Application.getInstance();
if (adapterClassName == null || AutoAdapter.class.getName().equals(adapterClassName)) {
return appInstance.getInjector().getInstance(DbAdapterFactory.class).createAdapter(null, makeDataSource(classLoader));
}
try {
return appInstance.getInjector().getInstance(AdhocObjectFactory.class).newInstance(DbAdapter.class, adapterClassName);
} catch (Throwable th) {
th = Util.unwindException(th);
throw new Exception("DbAdapter load error: " + th.getLocalizedMessage());
}
}
Aggregations