cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1072574 - in /cayenne/main/trunk/framework: cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/
Date Sun, 20 Feb 2011 12:26:03 GMT
Author: aadamchik
Date: Sun Feb 20 12:26:03 2011
New Revision: 1072574

URL: http://svn.apache.org/viewvc?rev=1072574&view=rev
Log:
CAY-1542 DI container is not shutting down Cayenne-managed connection pool

removing shutdown code from DataNode - DI should take care of it
other refactoring

Modified:
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultScopeProvider.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataNode.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/PoolManager.java

Modified: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultScopeProvider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultScopeProvider.java?rev=1072574&r1=1072573&r2=1072574&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultScopeProvider.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultScopeProvider.java
Sun Feb 20 12:26:03 2011
@@ -22,7 +22,7 @@ import org.apache.cayenne.ConfigurationE
 import org.apache.cayenne.di.Provider;
 
 /**
- * A provider that provides scoping for other provoders.
+ * A provider that provides scoping for other providers.
  * 
  * @since 3.1
  */

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java?rev=1072574&r1=1072573&r2=1072574&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
Sun Feb 20 12:26:03 2011
@@ -651,15 +651,7 @@ public class DataDomain implements Query
     public void shutdown() {
         if (!stopped) {
             if (sharedSnapshotCache != null) {
-                this.sharedSnapshotCache.shutdown();
-            }
-
-            for (DataNode node : getDataNodes()) {
-                try {
-                    node.shutdown();
-                }
-                catch (Exception ex) {
-                }
+                sharedSnapshotCache.shutdown();
             }
 
             stopped = true;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataNode.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataNode.java?rev=1072574&r1=1072573&r2=1072574&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataNode.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataNode.java
Sun Feb 20 12:26:03 2011
@@ -32,7 +32,6 @@ import javax.sql.DataSource;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.dbsync.SchemaUpdateStrategy;
 import org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy;
-import org.apache.cayenne.conn.PoolManager;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.EntityResolver;
@@ -167,7 +166,7 @@ public class DataNode implements QueryEn
     public void removeDataMap(DataMap map) {
         removeDataMap(map.getName());
     }
-  
+
     public void removeDataMap(String mapName) {
         dataMaps.remove(mapName);
     }
@@ -298,20 +297,11 @@ public class DataNode implements QueryEn
     }
 
     /**
-     * Tries to close JDBC connections opened by this node's data source.
+     * @deprecated since 3.1 does nothing as pool shutdown is performed by the DI
+     *             container.
      */
-    public synchronized void shutdown() {
-        try {
-            // TODO: theoretically someone maybe using our PoolManager as a container
-            // mapped DataSource, so we should use some other logic to determine whether
-            // this is a DataNode-managed DS.
-            if (dataSource instanceof PoolManager) {
-                ((PoolManager) dataSource).dispose();
-                dataSource = null;
-            }
-        }
-        catch (SQLException ex) {
-        }
+    public void shutdown() {
+        // noop
     }
 
     // a read-through DataSource that ensures returning the same connection within

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=1072574&r1=1072573&r2=1072574&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 Feb 20 12:26:03 2011
@@ -35,7 +35,6 @@ import javax.sql.PooledConnection;
 /**
  * PoolManager is a pooling DataSource impementation. Internally to obtain connections
  * PoolManager uses either a JDBC driver or another pooling datasource.
- * 
  */
 public class PoolManager implements DataSource, ConnectionEventListener {
 
@@ -168,8 +167,22 @@ public class PoolManager implements Data
         return connection;
     }
 
-    /** Closes all existing connections, removes them from the pool. */
+    /**
+     * Closes all existing connections, removes them from the pool.
+     * 
+     * @deprecated since 3.1 replaced with {@link #shutdown()} method for naming
+     *             consistency.
+     */
     public void dispose() throws SQLException {
+        shutdown();
+    }
+
+    /**
+     * Closes all existing connections, drains the pool and stops the maintenance thread.
+     * 
+     * @since 3.1
+     */
+    public void shutdown() throws SQLException {
         synchronized (this) {
             // clean connections from the pool
             ListIterator<PooledConnection> unusedIterator = unusedPool.listIterator();
@@ -199,7 +212,8 @@ public class PoolManager implements Data
 
     protected void disposeOfMaintenanceThread() {
         if (poolMaintenanceThread != null) {
-            this.poolMaintenanceThread.dispose();
+            poolMaintenanceThread.shutdown();
+            poolMaintenanceThread = null;
         }
     }
 
@@ -484,8 +498,8 @@ public class PoolManager implements Data
 
     static class PoolMaintenanceThread extends Thread {
 
-        protected boolean shouldDie;
-        protected PoolManager pool;
+        private boolean shouldDie;
+        private PoolManager pool;
 
         PoolMaintenanceThread(PoolManager pool) {
             super.setName("PoolManagerCleanup-" + pool.hashCode());
@@ -531,9 +545,9 @@ public class PoolManager implements Data
         }
 
         /**
-         * Stops the thread.
+         * Stops the maintenance thread.
          */
-        public void dispose() {
+        void shutdown() {
             shouldDie = true;
             interrupt();
         }



Mime
View raw message