cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1337846 - in /cayenne/main/trunk/framework: cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/c...
Date Sun, 13 May 2012 11:11:41 GMT
Author: aadamchik
Date: Sun May 13 11:11:40 2012
New Revision: 1337846

URL: http://svn.apache.org/viewvc?rev=1337846&view=rev
Log:
CAY-1706 Build support on JDK 1.7

second patch by Andrei Veprev - hiding JDBC differences between the JDK versions

Added:
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/ScopeEventListener.java
      - copied, changed from r1334903, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceProvider.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceFactory.java
Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceProvider.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DelegatingDataSourceFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/PoolManager.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderPartialTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelperProvider.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseDataSourceFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java

Copied: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/ScopeEventListener.java
(from r1334903, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceProvider.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/ScopeEventListener.java?p2=cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/ScopeEventListener.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceProvider.java&r1=1334903&r2=1337846&rev=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceProvider.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/ScopeEventListener.java
Sun May 13 11:11:40 2012
@@ -16,24 +16,20 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.unit.di.server;
+package org.apache.cayenne.di;
 
-import javax.sql.DataSource;
 
-import org.apache.cayenne.ConfigurationException;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.di.Provider;
-
-public class ServerCaseSharedDataSourceProvider implements Provider<DataSource> {
-
-    protected ServerCaseDataSourceFactory dataSourceFactory;
-
-    public ServerCaseSharedDataSourceProvider(
-            @Inject ServerCaseDataSourceFactory dataSourceFactory) {
-        this.dataSourceFactory = dataSourceFactory;
-    }
-
-    public DataSource get() throws ConfigurationException {
-        return dataSourceFactory.getSharedDataSource();
-    }
+/**
+ * This interface duplicates default reflection based mechanism for receiving DI events.
+ * It is not fully supported and its usage are reserved for cases when for some reason
+ * it is not possible to use reflection. It is used for example in
+ * {@link javax.sql.DataSource} managing layer to provide compatibility with java version
5.
+ *
+ * @since 3.1
+ */
+public interface ScopeEventListener {
+    /**
+     * Similar to {@link BeforeScopeEnd}
+     */
+    void beforeScopeEnd();
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DelegatingDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DelegatingDataSourceFactory.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DelegatingDataSourceFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DelegatingDataSourceFactory.java
Sun May 13 11:11:40 2012
@@ -18,12 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.configuration.server;
 
-import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.sql.DataSource;
-
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
@@ -31,10 +25,14 @@ import org.apache.cayenne.configuration.
 import org.apache.cayenne.di.AdhocObjectFactory;
 import org.apache.cayenne.di.BeforeScopeEnd;
 import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.di.spi.ScopeEventBinding;
+import org.apache.cayenne.di.ScopeEventListener;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import javax.sql.DataSource;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 /**
  * A {@link DataSourceFactory} that delegates DataSource creation to another factory,
  * which is determined dynamically per DataNodeDescriptor. The delegate class may be
@@ -59,10 +57,10 @@ public class DelegatingDataSourceFactory
     @Inject
     protected RuntimeProperties properties;
 
-    protected Map<DataSource, ScopeEventBinding> managedDataSources;
+    protected Map<DataSource, ScopeEventListener> managedDataSources;
 
     public DelegatingDataSourceFactory() {
-        managedDataSources = new ConcurrentHashMap<DataSource, ScopeEventBinding>();
+        managedDataSources = new ConcurrentHashMap<DataSource, ScopeEventListener>();
     }
 
     public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
@@ -74,8 +72,8 @@ public class DelegatingDataSourceFactory
 
     @BeforeScopeEnd
     public void shutdown() {
-        for (ScopeEventBinding binding : managedDataSources.values()) {
-            binding.onScopeEvent();
+        for (ScopeEventListener listener : managedDataSources.values()) {
+            listener.beforeScopeEnd();
         }
 
         managedDataSources.clear();
@@ -87,25 +85,9 @@ public class DelegatingDataSourceFactory
      */
     protected void attachToScope(DataSource dataSource) {
 
-        // no real thread-safety here, just checking to speed up processing... in the
-        // worst case we'll replace event binding for the same pool with an equivalent one
         if (!managedDataSources.containsKey(dataSource)) {
-
-            Class<BeforeScopeEnd> annotationType = BeforeScopeEnd.class;
-
-            // note that checking for class directly prevents wrapping... will wait till
-            // Java6/JDBC4 upgrade to check for wrappers
-            for (Method method : dataSource.getClass().getMethods()) {
-
-                if (method.isAnnotationPresent(annotationType)) {
-                    managedDataSources.put(dataSource, new ScopeEventBinding(
-                            dataSource,
-                            method));
-
-                    // no need to look further as we are supporting only a single scope
-                    // method
-                    break;
-                }
+            if (dataSource instanceof ScopeEventListener) {
+                managedDataSources.put(dataSource, (ScopeEventListener) dataSource);
             }
         }
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/PoolManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/PoolManager.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/PoolManager.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/PoolManager.java
Sun May 13 11:11:40 2012
@@ -19,6 +19,15 @@
 
 package org.apache.cayenne.conn;
 
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.di.ScopeEventListener;
+import org.apache.cayenne.log.JdbcEventLogger;
+
+import javax.sql.ConnectionEvent;
+import javax.sql.ConnectionEventListener;
+import javax.sql.ConnectionPoolDataSource;
+import javax.sql.DataSource;
+import javax.sql.PooledConnection;
 import java.io.PrintWriter;
 import java.sql.Connection;
 import java.sql.SQLException;
@@ -28,19 +37,10 @@ import java.util.List;
 import java.util.ListIterator;
 import java.util.logging.Logger;
 
-import javax.sql.ConnectionEvent;
-import javax.sql.ConnectionEventListener;
-import javax.sql.ConnectionPoolDataSource;
-import javax.sql.DataSource;
-import javax.sql.PooledConnection;
-
-import org.apache.cayenne.di.BeforeScopeEnd;
-import org.apache.cayenne.log.JdbcEventLogger;
-
 /**
  * PoolManager is a Cayenne implementation of a pooling DataSource.
  */
-public class PoolManager implements DataSource, ConnectionEventListener {
+public class PoolManager implements ScopeEventListener, DataSource, ConnectionEventListener
{
 
     /**
      * Defines a maximum time in milliseconds that a connection request could wait in the
@@ -188,7 +188,6 @@ public class PoolManager implements Data
      * 
      * @since 3.1
      */
-    @BeforeScopeEnd
     public synchronized void shutdown() throws SQLException {
         
         // disposing maintenance thread first to avoid any changes to pools
@@ -222,6 +221,15 @@ public class PoolManager implements Data
         }
     }
 
+    public void beforeScopeEnd() {
+        try {
+            shutdown();
+        }
+        catch (SQLException e) {
+            throw new CayenneRuntimeException("Error while shutting down");
+        }
+    }
+
     protected void disposeOfMaintenanceThread() {
         if (poolMaintenanceThread != null) {
             poolMaintenanceThread.shutdown();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java
Sun May 13 11:11:40 2012
@@ -43,6 +43,7 @@ import org.apache.cayenne.DataRow;
 import org.apache.cayenne.Fault;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.configuration.server.DataSourceFactory;
 import org.apache.cayenne.conn.PoolManager;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.exp.Expression;
@@ -68,6 +69,7 @@ import org.apache.cayenne.unit.UnitDbAda
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
 import org.apache.cayenne.unit.di.UnitTestClosure;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 @UseServerRuntime(ServerCase.TESTMAP_PROJECT)
@@ -86,7 +88,7 @@ public class DataContextTest extends Ser
     protected DataChannelInterceptor queryInterceptor;
 
     @Inject
-    protected DataSource dataSource;
+    protected ServerCaseDataSourceFactory dataSourceFactory;
 
     protected TableHelper tArtist;
     protected TableHelper tExhibit;
@@ -762,7 +764,7 @@ public class DataContextTest extends Ser
     }
 
     private void changeMaxConnections(int delta) {
-        PoolManager manager = (PoolManager) dataSource;
+        PoolManager manager = (PoolManager) dataSourceFactory.getSharedDataSource();
         manager.setMaxConnections(manager.getMaxConnections() + delta);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderPartialTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderPartialTest.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderPartialTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderPartialTest.java
Sun May 13 11:11:40 2012
@@ -21,8 +21,6 @@ package org.apache.cayenne.access;
 
 import java.util.Collection;
 
-import javax.sql.DataSource;
-
 import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.di.Inject;
@@ -30,6 +28,7 @@ import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 @UseServerRuntime(ServerCase.TESTMAP_PROJECT)
@@ -39,14 +38,14 @@ public class DbLoaderPartialTest extends
     private DbAdapter adapter;
 
     @Inject
-    private DataSource dataSource;
+    private ServerCaseDataSourceFactory dataSourceFactory;
 
     private DbLoader loader;
 
     @Override
     protected void setUpAfterInjection() throws Exception {
         loader = new DbLoader(
-                dataSource.getConnection(),
+                dataSourceFactory.getSharedDataSource().getConnection(),
                 adapter,
                 new DbLoaderDelegate() {
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
Sun May 13 11:11:40 2012
@@ -24,8 +24,6 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
-import javax.sql.DataSource;
-
 import org.apache.cayenne.configuration.server.ServerRuntime;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.TypesMapping;
@@ -38,6 +36,7 @@ import org.apache.cayenne.map.ObjAttribu
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 @UseServerRuntime(ServerCase.TESTMAP_PROJECT)
@@ -50,7 +49,7 @@ public class DbLoaderTest extends Server
     private DbAdapter adapter;
 
     @Inject
-    private DataSource dataSource;
+    private ServerCaseDataSourceFactory dataSourceFactory;
 
     @Inject
     private UnitDbAdapter accessStackAdapter;
@@ -59,7 +58,7 @@ public class DbLoaderTest extends Server
 
     @Override
     protected void setUpAfterInjection() throws Exception {
-        loader = new DbLoader(dataSource.getConnection(), adapter, null);
+        loader = new DbLoader(dataSourceFactory.getSharedDataSource().getConnection(), adapter,
null);
     }
 
     @Override

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
Sun May 13 11:11:40 2012
@@ -29,8 +29,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import javax.sql.DataSource;
-
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.MockOperationObserver;
@@ -43,6 +41,7 @@ import org.apache.cayenne.map.EntityReso
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 @UseServerRuntime(ServerCase.DEFAULT_PROJECT)
@@ -55,7 +54,7 @@ public class SchemaUpdateStrategyTest ex
     private DbAdapter adapter;
     
     @Inject
-    private DataSource dataSource;
+    private ServerCaseDataSourceFactory dataSourceFactory;
     
     @Inject
     private JdbcEventLogger jdbcEventLogger;
@@ -267,7 +266,7 @@ public class SchemaUpdateStrategyTest ex
         dataNode.setJdbcEventLogger(jdbcEventLogger);
         dataNode.setDataMaps(colection);
         dataNode.setAdapter(adapter);
-        dataNode.setDataSource(dataSource);
+        dataNode.setDataSource(dataSourceFactory.getSharedDataSource());
         dataNode.setDataSourceFactory(node.getDataSourceFactory());
         dataNode.setSchemaUpdateStrategyName(node.getSchemaUpdateStrategyName());
         dataNode.setEntityResolver(new EntityResolver(colection));

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveTest.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveTest.java
Sun May 13 11:11:40 2012
@@ -29,8 +29,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import javax.sql.DataSource;
-
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.access.MockOperationObserver;
@@ -43,6 +41,7 @@ import org.apache.cayenne.query.SelectQu
 import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 /**
@@ -52,7 +51,7 @@ import org.apache.cayenne.unit.di.server
 public class BindDirectiveTest extends ServerCase {
 
     @Inject
-    private DataSource dataSource;
+    private ServerCaseDataSourceFactory dataSourceFactory;
 
     @Inject
     private JdbcAdapter adapter;
@@ -234,7 +233,7 @@ public class BindDirectiveTest extends S
                 adapter,
                 context.getEntityResolver());
 
-        Connection c = dataSource.getConnection();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
         try {
             MockOperationObserver observer = new MockOperationObserver();
             action.performAction(c, observer);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java
Sun May 13 11:11:40 2012
@@ -26,8 +26,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.sql.DataSource;
-
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.access.DataNode;
@@ -43,6 +41,7 @@ import org.apache.cayenne.test.jdbc.DBHe
 import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.apache.cayenne.unit.util.SQLTemplateCustomizer;
 
@@ -50,7 +49,7 @@ import org.apache.cayenne.unit.util.SQLT
 public class SQLTemplateActionTest extends ServerCase {
 
     @Inject
-    protected DataSource dataSource;
+    protected ServerCaseDataSourceFactory dataSourceFactory;
 
     @Inject
     protected DataNode node;
@@ -118,7 +117,7 @@ public class SQLTemplateActionTest exten
         assertTrue(plan instanceof SQLTemplateAction);
 
         MockOperationObserver observer = new MockOperationObserver();
-        Connection c = dataSource.getConnection();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
 
         try {
             plan.performAction(c, observer);
@@ -157,7 +156,7 @@ public class SQLTemplateActionTest exten
         SQLAction plan = adapter.getAction(template, node);
 
         MockOperationObserver observer = new MockOperationObserver();
-        Connection c = dataSource.getConnection();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
 
         try {
             plan.performAction(c, observer);
@@ -190,7 +189,7 @@ public class SQLTemplateActionTest exten
         SQLAction plan = adapter.getAction(template, node);
 
         MockOperationObserver observer = new MockOperationObserver();
-        Connection c = dataSource.getConnection();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
 
         try {
             plan.performAction(c, observer);
@@ -223,7 +222,7 @@ public class SQLTemplateActionTest exten
         SQLAction plan = adapter.getAction(template, node);
 
         MockOperationObserver observer = new MockOperationObserver();
-        Connection c = dataSource.getConnection();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
 
         try {
             plan.performAction(c, observer);
@@ -255,7 +254,7 @@ public class SQLTemplateActionTest exten
 
         SQLAction action = adapter.getAction(template, node);
 
-        Connection c = dataSource.getConnection();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
         try {
             MockOperationObserver observer = new MockOperationObserver();
             action.performAction(c, observer);
@@ -283,7 +282,7 @@ public class SQLTemplateActionTest exten
 
         SQLAction action = adapter.getAction(template, node);
 
-        Connection c = dataSource.getConnection();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
         try {
             MockOperationObserver observer = new MockOperationObserver();
             action.performAction(c, observer);
@@ -323,7 +322,7 @@ public class SQLTemplateActionTest exten
         assertSame(adapter, action.getAdapter());
         assertSame(template, action.getQuery());
 
-        Connection c = dataSource.getConnection();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
         try {
             MockOperationObserver observer = new MockOperationObserver();
             action.performAction(c, observer);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
Sun May 13 11:11:40 2012
@@ -24,8 +24,6 @@ import java.sql.SQLException;
 import java.util.Date;
 import java.util.List;
 
-import javax.sql.DataSource;
-
 import org.apache.cayenne.access.DataContext;
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
 import org.apache.cayenne.dba.DbAdapter;
@@ -47,13 +45,14 @@ import org.apache.cayenne.testdo.testmap
 import org.apache.cayenne.testdo.testmap.CompoundPainting;
 import org.apache.cayenne.testdo.testmap.Painting;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 @UseServerRuntime(ServerCase.TESTMAP_PROJECT)
 public class SelectTranslatorTest extends ServerCase {
 
     @Inject
-    private DataSource dataSource;
+    private ServerCaseDataSourceFactory dataSourceFactory;
 
     @Inject
     private DataContext context;
@@ -1099,7 +1098,7 @@ public class SelectTranslatorTest extend
         void test(SelectQuery q) throws Exception {
             SelectTranslator transl = makeTranslator(q);
 
-            Connection c = dataSource.getConnection();
+            Connection c = dataSourceFactory.getSharedDataSource().getConnection();
             try {
 
                 transl.setConnection(c);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
Sun May 13 11:11:40 2012
@@ -28,16 +28,15 @@ import java.util.Calendar;
 import java.util.GregorianCalendar;
 import java.util.List;
 
-import javax.sql.DataSource;
-
 import org.apache.cayenne.MockSerializable;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 
 public class TypesMappingTest extends ServerCase {
 
     @Inject
-    private DataSource dataSource;
+    private ServerCaseDataSourceFactory dataSourceFactory;
 
     public void testGetSqlTypeByJava() throws Exception {
         assertEquals(Types.VARCHAR, TypesMapping.getSqlTypeByJava(String.class));
@@ -107,7 +106,7 @@ public class TypesMappingTest extends Se
     public void testTypeInfoCompleteness() throws Exception {
         // check counts
         // since more then 1 database type can map to a single JDBC type
-        Connection conn = dataSource.getConnection();
+        Connection conn = dataSourceFactory.getSharedDataSource().getConnection();
         int len = 0;
         try {
             DatabaseMetaData md = conn.getMetaData();
@@ -139,7 +138,7 @@ public class TypesMappingTest extends Se
     }
 
     TypesMapping createTypesMapping() throws Exception {
-        Connection conn = dataSource.getConnection();
+        Connection conn = dataSourceFactory.getSharedDataSource().getConnection();
 
         try {
             DatabaseMetaData md = conn.getMetaData();

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=1337846&r1=1337845&r2=1337846&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
Sun May 13 11:11:40 2012
@@ -22,21 +22,20 @@ package org.apache.cayenne.dba.sqlserver
 import java.sql.Connection;
 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;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 @UseServerRuntime(ServerCase.TESTMAP_PROJECT)
 public class SQLServerSnifferTest extends ServerCase {
 
     @Inject
-    private DataSource dataSource;
+    private ServerCaseDataSourceFactory dataSourceFactory;
 
     @Inject
     private UnitDbAdapter accessStackAdapter;
@@ -49,7 +48,7 @@ public class SQLServerSnifferTest extend
         SQLServerSniffer sniffer = new SQLServerSniffer(objectFactory);
 
         DbAdapter adapter = null;
-        Connection c = dataSource.getConnection();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
 
         try {
             adapter = sniffer.createAdapter(c.getMetaData());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java
Sun May 13 11:11:40 2012
@@ -25,8 +25,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import javax.sql.DataSource;
-
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.configuration.server.ServerRuntime;
 import org.apache.cayenne.dba.DbAdapter;
@@ -37,6 +35,7 @@ import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 
 public abstract class MergeCase extends ServerCase {
 
@@ -47,7 +46,7 @@ public abstract class MergeCase extends 
     private UnitDbAdapter accessStackAdapter;
 
     @Inject
-    private DataSource dataSource;
+    private ServerCaseDataSourceFactory dataSourceFactory;
 
     @Inject
     protected EntityResolver resolver;
@@ -139,7 +138,7 @@ public abstract class MergeCase extends 
     }
 
     private void executeSql(String sql) throws Exception {
-        Connection conn = dataSource.getConnection();
+        Connection conn = dataSourceFactory.getSharedDataSource().getConnection();
 
         try {
             Statement st = conn.createStatement();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelperProvider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelperProvider.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelperProvider.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelperProvider.java
Sun May 13 11:11:40 2012
@@ -18,8 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.unit.di.server;
 
-import javax.sql.DataSource;
-
 import org.apache.cayenne.ConfigurationException;
 import org.apache.cayenne.DataChannel;
 import org.apache.cayenne.configuration.server.ServerRuntime;
@@ -32,7 +30,7 @@ import org.apache.cayenne.test.jdbc.DBHe
 public class FlavoredDBHelperProvider implements Provider<DBHelper> {
 
     @Inject
-    protected DataSource dataSource;
+    protected ServerCaseDataSourceFactory dataSourceFactory;
 
     @Inject
     // injecting provider to make this provider independent from scoping of ServerRuntime
@@ -45,7 +43,7 @@ public class FlavoredDBHelperProvider im
 
         DataChannel channel = serverRuntimeProvider.get().getChannel();
         DataMap firstMap = channel.getEntityResolver().getDataMaps().iterator().next();
-        return new FlavoredDBHelper(dataSource, adapter.getQuotingStrategy(firstMap
-                .isQuotingSQLIdentifiers()));
+        return new FlavoredDBHelper(dataSourceFactory.getSharedDataSource(),
+                adapter.getQuotingStrategy(firstMap.isQuotingSQLIdentifiers()));
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
Sun May 13 11:11:40 2012
@@ -81,16 +81,16 @@ public class SchemaBuilder {
         "CLOB_DETAIL"
     };
 
-    private DataSource dataSource;
+    private ServerCaseDataSourceFactory dataSourceFactory;
     private UnitDbAdapter unitDbAdapter;
     private DbAdapter dbAdapter;
     private DataDomain domain;
     private JdbcEventLogger jdbcEventLogger;
 
-    public SchemaBuilder(@Inject DataSource dataSource,
+    public SchemaBuilder(@Inject ServerCaseDataSourceFactory dataSourceFactory,
             @Inject UnitDbAdapter unitDbAdapter, @Inject DbAdapter dbAdapter,
             @Inject JdbcEventLogger jdbcEventLogger) {
-        this.dataSource = dataSource;
+        this.dataSourceFactory = dataSourceFactory;
         this.unitDbAdapter = unitDbAdapter;
         this.dbAdapter = dbAdapter;
         this.jdbcEventLogger = jdbcEventLogger;
@@ -146,7 +146,7 @@ public class SchemaBuilder {
         DataNode node = new DataNode(map.getName());
         node.setJdbcEventLogger(jdbcEventLogger);
         node.setAdapter(dbAdapter);
-        node.setDataSource(dataSource);
+        node.setDataSource(dataSourceFactory.getSharedDataSource());
 
         // setup test extended types
         node.getAdapter().getExtendedTypes().registerType(new StringET1ExtendedType());
@@ -264,7 +264,7 @@ public class SchemaBuilder {
     }
 
     private void dropSchema(DataNode node, DataMap map) throws Exception {
-        Connection conn = dataSource.getConnection();
+        Connection conn = dataSourceFactory.getSharedDataSource().getConnection();
         List<DbEntity> list = dbEntitiesInInsertOrder(node, map);
 
         try {
@@ -326,7 +326,7 @@ public class SchemaBuilder {
     }
 
     private void createSchema(DataNode node, DataMap map) throws Exception {
-        Connection conn = dataSource.getConnection();
+        Connection conn = dataSourceFactory.getSharedDataSource().getConnection();
 
         try {
             unitDbAdapter.willCreateTables(conn, map);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseDataSourceFactory.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseDataSourceFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseDataSourceFactory.java
Sun May 13 11:11:40 2012
@@ -27,12 +27,14 @@ import java.util.Set;
 
 import javax.sql.DataSource;
 
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.configuration.server.DataSourceFactory;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.conn.PoolDataSource;
 import org.apache.cayenne.conn.PoolManager;
 import org.apache.cayenne.di.Inject;
 
-public class ServerCaseDataSourceFactory {
+public class ServerCaseDataSourceFactory  {
 
     private DataSource sharedDataSource;
     private DataSourceInfo dataSourceInfo;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java?rev=1337846&r1=1337845&r2=1337846&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
Sun May 13 11:11:40 2012
@@ -52,6 +52,7 @@ import org.apache.cayenne.configuration.
 import org.apache.cayenne.configuration.DefaultRuntimeProperties;
 import org.apache.cayenne.configuration.ObjectStoreFactory;
 import org.apache.cayenne.configuration.RuntimeProperties;
+import org.apache.cayenne.configuration.server.DataSourceFactory;
 import org.apache.cayenne.configuration.server.ServerRuntime;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.dba.DbAdapter;
@@ -181,9 +182,7 @@ public class ServerCaseModule implements
 
         binder.bind(DataSourceInfo.class).toProvider(
                 ServerCaseDataSourceInfoProvider.class);
-        binder
-                .bind(DataSource.class)
-                .toProvider(ServerCaseSharedDataSourceProvider.class);
+        binder.bind(DataSourceFactory.class).to(ServerCaseSharedDataSourceFactory.class);
         binder.bind(DbAdapter.class).toProvider(ServerCaseDbAdapterProvider.class);
         binder.bind(JdbcAdapter.class).toProvider(ServerCaseDbAdapterProvider.class);
         binder.bind(UnitDbAdapter.class).toProvider(UnitDbAdapterProvider.class);

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceFactory.java?rev=1337846&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceFactory.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSharedDataSourceFactory.java
Sun May 13 11:11:40 2012
@@ -0,0 +1,19 @@
+package org.apache.cayenne.unit.di.server;
+
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.configuration.server.DataSourceFactory;
+import org.apache.cayenne.di.Inject;
+
+import javax.sql.DataSource;
+
+public class ServerCaseSharedDataSourceFactory implements DataSourceFactory {
+
+    private ServerCaseDataSourceFactory factory;
+
+    public ServerCaseSharedDataSourceFactory(@Inject ServerCaseDataSourceFactory factory)
{
+    }
+
+    public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
+        return factory.getSharedDataSource();
+    }
+}



Mime
View raw message