Search in sources :

Example 1 with Application

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());
    }
}
Also used : DbAdapterFactory(org.apache.cayenne.configuration.server.DbAdapterFactory) AdhocObjectFactory(org.apache.cayenne.di.AdhocObjectFactory) Application(org.apache.cayenne.modeler.Application) SQLException(java.sql.SQLException)

Aggregations

SQLException (java.sql.SQLException)1 DbAdapterFactory (org.apache.cayenne.configuration.server.DbAdapterFactory)1 AdhocObjectFactory (org.apache.cayenne.di.AdhocObjectFactory)1 Application (org.apache.cayenne.modeler.Application)1