cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject svn commit: r1170516 - in /cayenne/main/trunk: framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/ framework/cayenne-jdk1.5-unpublishe...
Date Wed, 14 Sep 2011 10:29:10 GMT
Author: dkazimirchyk
Date: Wed Sep 14 10:29:09 2011
New Revision: 1170516

URL: http://svn.apache.org/viewvc?rev=1170516&view=rev
Log:
CAY-1618 Create database adapters instances with proper injection

db adapters sniffers refactoring + removed deprecated methods from AutoAdapter that we can't
longer support

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGeneratorPostprocessor.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Sniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbySniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2Sniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseSniffer.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferTest.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBConnectionInfo.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerDbAdapter.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java
Wed Sep 14 10:29:09 2011
@@ -356,7 +356,7 @@ public class DbGenerator {
                 }
             }
 
-            new DbGeneratorPostprocessor().execute(connection);
+            new DbGeneratorPostprocessor().execute(connection, getAdapter());
         }
         finally {
             connection.close();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGeneratorPostprocessor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGeneratorPostprocessor.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGeneratorPostprocessor.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGeneratorPostprocessor.java
Wed Sep 14 10:29:09 2011
@@ -43,10 +43,8 @@ class DbGeneratorPostprocessor {
         postprocessors.put(HSQLDBAdapter.class.getName(), new HSQLDBPostprocessor());
     }
 
-    void execute(Connection connection) throws SQLException {
+    void execute(Connection connection, DbAdapter adapter) throws SQLException {
 
-        DbAdapter adapter = AutoAdapter.getDefaultFactory().createAdapter(
-                connection.getMetaData());
         if (adapter != null) {
             Postprocessor postprocessor = postprocessors.get(adapter
                     .getClass()

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactory.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactory.java
Wed Sep 14 10:29:09 2011
@@ -68,8 +68,13 @@ public class DefaultDbAdapterFactory imp
     public DbAdapter createAdapter(
             final DataNodeDescriptor nodeDescriptor,
             final DataSource dataSource) throws Exception {
+        
+        String adapterType = null;
+        
+        if (nodeDescriptor != null) {
+            adapterType = nodeDescriptor.getAdapterType();
+        }
 
-        String adapterType = nodeDescriptor.getAdapterType();
         if (adapterType != null) {
             return objectFactory.newInstance(DbAdapter.class, adapterType);
         }
@@ -77,15 +82,13 @@ public class DefaultDbAdapterFactory imp
             return new AutoAdapter(new Provider<DbAdapter>() {
 
                 public DbAdapter get() {
-                    return detectAdapter(nodeDescriptor, dataSource);
+                    return detectAdapter(dataSource);
                 }
             }, jdbcEventLogger);
         }
     }
 
-    protected DbAdapter detectAdapter(
-            DataNodeDescriptor nodeDescriptor,
-            DataSource dataSource) {
+    protected DbAdapter detectAdapter(DataSource dataSource) {
 
         if (detectors.isEmpty()) {
             return defaultAdapter();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
Wed Sep 14 10:29:09 2011
@@ -100,24 +100,27 @@ public class ServerModule implements Mod
         binder.bindMap(DefaultRuntimeProperties.PROPERTIES_MAP);
 
         binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
+        
+        AdhocObjectFactory objectFactory = new DefaultAdhocObjectFactory();
+        binder.bind(AdhocObjectFactory.class).toInstance(objectFactory);
 
         // configure known DbAdapter detectors in reverse order of popularity. Users can
         // add their own to install custom adapters automatically
         binder
                 .bindList(DefaultDbAdapterFactory.DETECTORS_LIST)
-                .add(new OpenBaseSniffer())
-                .add(new FrontBaseSniffer())
-                .add(new IngresSniffer())
-                .add(new SQLiteSniffer())
-                .add(new DB2Sniffer())
-                .add(new H2Sniffer())
-                .add(new HSQLDBSniffer())
-                .add(new SybaseSniffer())
-                .add(new DerbySniffer())
-                .add(new SQLServerSniffer())
-                .add(new OracleSniffer())
-                .add(new PostgresSniffer())
-                .add(new MySQLSniffer());
+                .add(new OpenBaseSniffer(objectFactory))
+                .add(new FrontBaseSniffer(objectFactory))
+                .add(new IngresSniffer(objectFactory))
+                .add(new SQLiteSniffer(objectFactory))
+                .add(new DB2Sniffer(objectFactory))
+                .add(new H2Sniffer(objectFactory))
+                .add(new HSQLDBSniffer(objectFactory))
+                .add(new SybaseSniffer(objectFactory))
+                .add(new DerbySniffer(objectFactory))
+                .add(new SQLServerSniffer(objectFactory))
+                .add(new OracleSniffer(objectFactory))
+                .add(new PostgresSniffer(objectFactory))
+                .add(new MySQLSniffer(objectFactory));
 
         // configure an empty filter chain
         binder.bindList(DataDomainProvider.FILTERS_LIST);
@@ -129,7 +132,6 @@ public class ServerModule implements Mod
             locationsListBuilder.add(location);
         }
 
-        binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
         binder.bind(ConfigurationNameMapper.class).to(
                 DefaultConfigurationNameMapper.class);
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
Wed Sep 14 10:29:09 2011
@@ -19,34 +19,15 @@
 
 package org.apache.cayenne.dba;
 
-import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
-import java.util.List;
-
-import javax.sql.DataSource;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.trans.QualifierTranslator;
 import org.apache.cayenne.access.trans.QueryAssembler;
 import org.apache.cayenne.access.types.ExtendedTypeMap;
-import org.apache.cayenne.dba.db2.DB2Sniffer;
-import org.apache.cayenne.dba.derby.DerbySniffer;
-import org.apache.cayenne.dba.frontbase.FrontBaseSniffer;
-import org.apache.cayenne.dba.h2.H2Sniffer;
-import org.apache.cayenne.dba.hsqldb.HSQLDBSniffer;
-import org.apache.cayenne.dba.ingres.IngresSniffer;
-import org.apache.cayenne.dba.mysql.MySQLSniffer;
-import org.apache.cayenne.dba.openbase.OpenBaseSniffer;
-import org.apache.cayenne.dba.oracle.OracleSniffer;
-import org.apache.cayenne.dba.postgres.PostgresSniffer;
-import org.apache.cayenne.dba.sqlite.SQLiteSniffer;
-import org.apache.cayenne.dba.sqlserver.SQLServerSniffer;
-import org.apache.cayenne.dba.sybase.SybaseSniffer;
 import org.apache.cayenne.di.Provider;
 import org.apache.cayenne.log.JdbcEventLogger;
 import org.apache.cayenne.map.DbAttribute;
@@ -65,58 +46,6 @@ import org.apache.cayenne.query.SQLActio
  */
 public class AutoAdapter implements DbAdapter {
 
-    /**
-     * @deprecated since 3.1 in favor of
-     *             {@link org.apache.cayenne.configuration.server.DbAdapterFactory}
-     *             configured via dependency injection.
-     */
-    static final List<DbAdapterFactory> defaultFactories;
-
-    static {
-
-        defaultFactories = new ArrayList<DbAdapterFactory>();
-
-        // hardcoded factories for adapters that we know how to auto-detect
-        defaultFactories.addAll(Arrays.asList(
-                new MySQLSniffer(),
-                new PostgresSniffer(),
-                new OracleSniffer(),
-                new SQLServerSniffer(),
-                new HSQLDBSniffer(),
-                new DB2Sniffer(),
-                new SybaseSniffer(),
-                new DerbySniffer(),
-                new OpenBaseSniffer(),
-                new FrontBaseSniffer(),
-                new IngresSniffer(),
-                new SQLiteSniffer(),
-                new H2Sniffer()));
-    }
-
-    /**
-     * Allows application code to add a sniffer to detect a custom adapter.
-     * 
-     * @since 3.0
-     * @deprecated since 3.1 in favor of
-     *             {@link org.apache.cayenne.configuration.server.DbAdapterFactory}
-     *             configured via dependency injection.
-     */
-    public static void addFactory(DbAdapterFactory factory) {
-        defaultFactories.add(factory);
-    }
-
-    /**
-     * Returns a DbAdapterFactory configured to detect all databases officially supported
-     * by Cayenne.
-     * 
-     * @deprecated since 3.1 in favor of
-     *             {@link org.apache.cayenne.configuration.server.DbAdapterFactory}
-     *             configured via dependency injection.
-     */
-    public static DbAdapterFactory getDefaultFactory() {
-        return new DbAdapterFactoryChain(defaultFactories);
-    }
-
     protected Provider<DbAdapter> adapterProvider;
     protected PkGenerator pkGenerator;
     protected JdbcEventLogger logger;
@@ -127,71 +56,6 @@ public class AutoAdapter implements DbAd
     volatile DbAdapter adapter;
 
     /**
-     * Creates an AutoAdapter that can detect adapters known to Cayenne.
-     * 
-     * @deprecated since 3.1 use {@link #AutoAdapter(Provider)}
-     */
-    public AutoAdapter(DataSource dataSource) {
-        this((DbAdapterFactory) null, dataSource);
-    }
-
-    /**
-     * Creates an AutoAdapter with specified adapter factory and DataSource. If
-     * adapterFactory is null, default factory is used.
-     * 
-     * @deprecated since 3.1 use {@link #AutoAdapter(Provider)}
-     */
-    public AutoAdapter(DbAdapterFactory adapterFactory, final DataSource dataSource) {
-        // sanity check
-        if (dataSource == null) {
-            throw new CayenneRuntimeException("Null dataSource");
-        }
-
-        final DbAdapterFactory deprecatedFactory = adapterFactory != null
-                ? adapterFactory
-                : createDefaultFactory();
-
-        this.adapterProvider = new Provider<DbAdapter>() {
-
-            public DbAdapter get() {
-                DbAdapter adapter;
-
-                try {
-                    Connection c = dataSource.getConnection();
-
-                    try {
-                        adapter = deprecatedFactory.createAdapter(c.getMetaData());
-                    }
-                    finally {
-                        try {
-                            c.close();
-                        }
-                        catch (SQLException e) {
-                            // ignore...
-                        }
-                    }
-                }
-                catch (SQLException e) {
-                    throw new CayenneRuntimeException("Error detecting database type: "
-                            + e.getLocalizedMessage(), e);
-                }
-
-                if (adapter == null) {
-                    logger.log("Failed to detect database type, using default adapter");
-                    adapter = new JdbcAdapter();
-                }
-                else {
-                    logger.log("Detected and installed adapter: "
-                            + adapter.getClass().getName());
-                }
-
-                return adapter;
-            }
-        };
-
-    }
-
-    /**
      * Creates an {@link AutoAdapter} based on a delegate adapter obtained via
      * "adapterProvider".
      * 
@@ -208,18 +72,6 @@ public class AutoAdapter implements DbAd
     }
 
     /**
-     * Called from constructor to initialize factory in case no factory was specified by
-     * the object creator.
-     * 
-     * @deprecated since 3.1 in favor of
-     *             {@link org.apache.cayenne.configuration.server.DbAdapterFactory}
-     *             configured via dependency injection.
-     */
-    protected DbAdapterFactory createDefaultFactory() {
-        return getDefaultFactory();
-    }
-
-    /**
      * Returns a proxied DbAdapter, lazily creating it on first invocation.
      */
     protected DbAdapter getAdapter() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Sniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Sniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Sniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Sniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,16 +25,24 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * @since 1.2
  */
 public class DB2Sniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public DB2Sniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
         return dbName != null && dbName.toUpperCase().contains("DB2")
-                ? new DB2Adapter()
+                ? objectFactory.newInstance(DbAdapter.class, DB2Adapter.class.getName())
                 : null;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbySniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbySniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbySniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbySniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,6 +25,8 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * Creates a DerbyAdapter if Apache Derby database is detected.
@@ -32,11 +34,17 @@ import org.apache.cayenne.dba.DbAdapterF
  * @since 1.2
  */
 public class DerbySniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public DerbySniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
         return dbName != null && dbName.toUpperCase().contains("APACHE DERBY")
-                ? new DerbyAdapter()
+                ? objectFactory.newInstance(DbAdapter.class, DerbyAdapter.class.getName())
                 : null;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseSniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,16 +25,26 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * @since 1.2
  */
 public class FrontBaseSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public FrontBaseSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
         return dbName != null && dbName.toUpperCase().contains("FRONTBASE")
-                ? new FrontBaseAdapter()
+                ? objectFactory.newInstance(
+                        DbAdapter.class, 
+                        FrontBaseAdapter.class.getName())
                 : null;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2Sniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2Sniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2Sniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2Sniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,16 +25,24 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * @since 3.0
  */
 public class H2Sniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public H2Sniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
         return dbName != null && dbName.toUpperCase().contains("H2")
-                ? new H2Adapter()
+                ? objectFactory.newInstance(DbAdapter.class, H2Adapter.class.getName())
                 : null;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBSniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,6 +25,8 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * Detects HSQLDB database from JDBC metadata.
@@ -32,6 +34,12 @@ import org.apache.cayenne.dba.DbAdapterF
  * @since 1.2
  */
 public class HSQLDBSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public HSQLDBSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
@@ -56,7 +64,9 @@ public class HSQLDBSniffer implements Db
         }
         
         return supportsSchema
-            ? new HSQLDBAdapter()
-            : new HSQLDBNoSchemaAdapter();
+            ? objectFactory.newInstance(DbAdapter.class, HSQLDBAdapter.class.getName())
+            : objectFactory.newInstance(
+                    DbAdapter.class, 
+                    HSQLDBNoSchemaAdapter.class.getName());
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresSniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,6 +25,8 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * Detects Ingres database from JDBC metadata.
@@ -32,11 +34,17 @@ import org.apache.cayenne.dba.DbAdapterF
  * @since 1.2
  */
 public class IngresSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public IngresSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
         return dbName != null && dbName.toUpperCase().contains("INGRES")
-                ? new IngresAdapter()
+                ? objectFactory.newInstance(DbAdapter.class, IngresAdapter.class.getName())
                 : null;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLSniffer.java
Wed Sep 14 10:29:09 2011
@@ -27,6 +27,8 @@ import java.sql.Statement;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * Detects MySQL database from JDBC metadata.
@@ -34,6 +36,12 @@ import org.apache.cayenne.dba.DbAdapterF
  * @since 1.2
  */
 public class MySQLSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public MySQLSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
@@ -69,7 +77,9 @@ public class MySQLSniffer implements DbA
             statement.close();
         }
 
-        MySQLAdapter adapter = new MySQLAdapter();
+        MySQLAdapter adapter = objectFactory.newInstance(
+                MySQLAdapter.class, 
+                MySQLAdapter.class.getName());
         adapter.setSupportsFkConstraints(supportFK);
         adapter.setStorageEngine(adapterStorageEngine);
         return adapter;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseSniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,6 +25,8 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * Detects OpenBase DB from JDBC metadata.
@@ -32,11 +34,17 @@ import org.apache.cayenne.dba.DbAdapterF
  * @since 1.2
  */
 public class OpenBaseSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public OpenBaseSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
         return dbName != null && dbName.toUpperCase().contains("OPENBASE")
-                ? new OpenBaseAdapter()
+                ? objectFactory.newInstance(DbAdapter.class, OpenBaseAdapter.class.getName())
                 : null;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,11 +25,19 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * @since 1.2
  */
 public class OracleSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public OracleSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
@@ -38,7 +46,7 @@ public class OracleSniffer implements Db
         }
 
         return (md.getDriverMajorVersion() <= 8)
-                ? new Oracle8Adapter()
-                : new OracleAdapter();
+                ? objectFactory.newInstance(DbAdapter.class, Oracle8Adapter.class.getName())
+                : objectFactory.newInstance(DbAdapter.class, OracleAdapter.class.getName());
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,16 +25,24 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * @since 1.2
  */
 public class PostgresSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public PostgresSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
         return dbName != null && dbName.toUpperCase().contains("POSTGRESQL")
-                ? new PostgresAdapter()
+                ? objectFactory.newInstance(DbAdapter.class, PostgresAdapter.class.getName())
                 : null;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSniffer.java
Wed Sep 14 10:29:09 2011
@@ -24,6 +24,8 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * Detects SQLite database from JDBC metadata.
@@ -31,6 +33,12 @@ import org.apache.cayenne.dba.DbAdapterF
  * @since 3.0
  */
 public class SQLiteSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public SQLiteSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
@@ -38,6 +46,6 @@ public class SQLiteSniffer implements Db
             return null;
         }
 
-        return new SQLiteAdapter();
+        return objectFactory.newInstance(DbAdapter.class, SQLiteAdapter.class.getName());
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,6 +25,8 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * Detects SQLServer database from JDBC metadata.
@@ -32,6 +34,12 @@ import org.apache.cayenne.dba.DbAdapterF
  * @since 1.2
  */
 public class SQLServerSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public SQLServerSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
         String dbName = md.getDatabaseProductName();
@@ -39,7 +47,9 @@ public class SQLServerSniffer implements
             return null;
         }
 
-        SQLServerAdapter adapter = new SQLServerAdapter();
+        SQLServerAdapter adapter = objectFactory.newInstance(
+                SQLServerAdapter.class, 
+                SQLServerAdapter.class.getName());
 
         // detect whether generated keys are supported
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseSniffer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseSniffer.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseSniffer.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseSniffer.java
Wed Sep 14 10:29:09 2011
@@ -25,6 +25,8 @@ import java.sql.SQLException;
 import org.apache.cayenne.configuration.server.DbAdapterDetector;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
 
 /**
  * Detects Sybase database from JDBC metadata.
@@ -32,6 +34,12 @@ import org.apache.cayenne.dba.DbAdapterF
  * @since 1.2
  */
 public class SybaseSniffer implements DbAdapterFactory, DbAdapterDetector {
+    
+    protected AdhocObjectFactory objectFactory;
+    
+    public SybaseSniffer(@Inject AdhocObjectFactory objectFactory) {
+        this.objectFactory = objectFactory;
+    }
 
     public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {    	
     	// JTDS driver returns "sql server" for Sybase, so need to handle it differently
@@ -39,13 +47,13 @@ public class SybaseSniffer implements Db
     	if(driver != null && driver.toLowerCase().startsWith("jtds")) {
     		String url = md.getURL();
     		return url != null && url.toLowerCase().startsWith("jdbc:jtds:sybase:")
-    		        ? new SybaseAdapter()
+    		        ? objectFactory.newInstance(DbAdapter.class, SybaseAdapter.class.getName())
                     : null;
     	}
     	else {
             String dbName = md.getDatabaseProductName();
             return dbName != null && dbName.toUpperCase().contains("ADAPTIVE SERVER")
-                    ? new SybaseAdapter()
+                    ? objectFactory.newInstance(DbAdapter.class, SybaseAdapter.class.getName())
                     : null;
     	}
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferTest.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferTest.java
Wed Sep 14 10:29:09 2011
@@ -25,6 +25,7 @@ import java.sql.SQLException;
 import javax.sql.DataSource;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.di.AdhocObjectFactory;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.SQLServerUnitDbAdapter;
@@ -39,10 +40,13 @@ public class SQLServerSnifferTest extend
 
     @Inject
     private UnitDbAdapter accessStackAdapter;
+    
+    @Inject
+    private AdhocObjectFactory objectFactory;
 
     public void testCreateAdapter() throws Exception {
 
-        SQLServerSniffer sniffer = new SQLServerSniffer();
+        SQLServerSniffer sniffer = new SQLServerSniffer(objectFactory);
 
         DbAdapter adapter = null;
         Connection c = dataSource.getConnection();

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBConnectionInfo.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBConnectionInfo.java?rev=1170516&r1=1170515&r2=1170516&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBConnectionInfo.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBConnectionInfo.java
Wed Sep 14 10:29:09 2011
@@ -25,10 +25,13 @@ import java.util.prefs.Preferences;
 
 import javax.sql.DataSource;
 
+import org.apache.cayenne.configuration.server.DbAdapterFactory;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.conn.DriverDataSource;
 import org.apache.cayenne.dba.AutoAdapter;
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ClassLoadingService;
 import org.apache.cayenne.pref.CayennePreference;
 import org.apache.cayenne.util.Util;
@@ -179,14 +182,21 @@ public class DBConnectionInfo extends Ca
      */
     public DbAdapter makeAdapter(ClassLoadingService classLoader) throws Exception {
         String adapterClassName = getDbAdapter();
+        Application appInstance = Application.getInstance();
 
         if (adapterClassName == null
                 || AutoAdapter.class.getName().equals(adapterClassName)) {
-            return new AutoAdapter(makeDataSource(classLoader));
+            return appInstance
+                    .getInjector()
+                    .getInstance(DbAdapterFactory.class)
+                    .createAdapter(null, makeDataSource(classLoader));
         }
 
         try {
-            return classLoader.loadClass(DbAdapter.class, adapterClassName).newInstance();
+            return appInstance
+                    .getInjector()
+                    .getInstance(AdhocObjectFactory.class)
+                    .newInstance(DbAdapter.class, adapterClassName);
         }
         catch (Throwable th) {
             th = Util.unwindException(th);



Mime
View raw message