Remove the Driver class, its not used anymore, and if it was used, there needs to...
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 25 Nov 2008 23:37:00 +0000 (23:37 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 25 Nov 2008 23:37:00 +0000 (23:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@720668 13f79535-47bb-0310-9956-ffa450edef68

modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/Driver.java [deleted file]

index c5bb1fc..0391001 100644 (file)
@@ -41,7 +41,7 @@ import org.apache.juli.logging.LogFactory;
 public class DataSourceProxy  {
     protected static Log log = LogFactory.getLog(DataSourceProxy.class);
     
-    protected Driver driver;
+    protected volatile ConnectionPool pool = null;
     protected PoolProperties poolProperties = new PoolProperties();
 
     public DataSourceProxy() {
@@ -75,12 +75,12 @@ public class DataSourceProxy  {
      * @return Driver
      * @throws SQLException
      */
-    public synchronized Driver createDriver() throws SQLException {
-        if (driver != null) {
-            return driver;
+    public synchronized ConnectionPool createPool() throws SQLException {
+        if (pool != null) {
+            return pool;
         } else {
-            driver = new org.apache.tomcat.jdbc.pool.Driver(getPoolProperties());
-            return driver;
+            pool = new ConnectionPool(poolProperties);
+            return pool;
         }
     }
 
@@ -89,9 +89,9 @@ public class DataSourceProxy  {
      */
 
     public Connection getConnection() throws SQLException {
-        if (driver == null)
-            driver = createDriver();
-        return driver.connect(poolProperties.getPoolName(), null);
+        if (pool == null)
+            return createPool().getConnection();
+        return pool.getConnection();
     }
 
     /**
@@ -151,10 +151,10 @@ public class DataSourceProxy  {
     }
     public void close(boolean all) {
         try {
-            if (driver != null) {
-                Driver d = driver;
-                driver = null;
-                d.closePool(poolProperties.getPoolName(), all);
+            if (pool != null) {
+                final ConnectionPool p = pool;
+                pool = null;
+                if (p!=null) p.close(all);
             }
         }catch (Exception x) {
             x.printStackTrace();
@@ -167,9 +167,9 @@ public class DataSourceProxy  {
     }
 
     public int getPoolSize() throws SQLException{
-        if (driver == null)
-            driver = createDriver();
-        return driver.getPool(getPoolProperties().getPoolName()).getSize();
+        final ConnectionPool p = pool;
+        if (p == null) return 0;
+        else return p.getSize();
     }
 
     public String toString() {
diff --git a/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/Driver.java b/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/Driver.java
deleted file mode 100644 (file)
index 85d3861..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.pool;
-
-
-import java.sql.Connection;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Properties;
-
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-/**
- * @author Filip Hanik
- * @version 1.0
- */
-public class Driver implements java.sql.Driver {
-
-    protected static Log log = LogFactory.getLog(Driver.class);
-
-    protected static HashMap pooltable = new HashMap(11);
-
-    public Driver() throws SQLException {
-    }
-
-    public Driver(PoolProperties properties) throws SQLException {
-        init(properties);
-    } //Driver
-
-    public void init(PoolProperties properties) throws SQLException {
-        if (pooltable.get(properties.getPoolName()) != null)
-            throw new SQLException("Pool identified by:" + properties.getPoolName() + " already exists.");
-        ConnectionPool pool = new ConnectionPool(properties);
-        pooltable.put(properties.getPoolName(), pool);
-    }
-
-    public void closePool(String url, boolean all) throws SQLException {
-        ConnectionPool pool = (ConnectionPool) pooltable.get(url);
-        if (pool == null) {
-            throw new SQLException("No connection pool established for URL:" + url);
-        } else {
-            pool.close(all);
-        }
-        pooltable.remove(url);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Connection connect(String url, Properties info) throws SQLException {
-        ConnectionPool pool = (ConnectionPool) pooltable.get(url);
-        if (pool == null) {
-            throw new SQLException("No connection pool established for URL:" + url);
-        } else {
-            try {
-                return pool.getConnection();
-            } catch (SQLException forward) {
-                throw forward;
-            } catch (Exception e) {
-                throw new SQLException("Unknow pool exception:" + ConnectionPool.getStackTrace(e));
-            } //catch
-        } //end if
-    } //connect
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean acceptsURL(String url) throws SQLException {
-        /* check if the driver has a connection pool with that name */
-        return (pooltable.get(url) != null ? true : false);
-    } //acceptsUrl
-
-    /**
-     * {@inheritDoc}
-     */
-    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws
-        SQLException {
-        return new DriverPropertyInfo[0];
-    } //getPropertyInfo
-
-    /**
-     * {@inheritDoc}
-     */
-    public int getMajorVersion() {
-        return 1;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int getMinorVersion() {
-        return 0;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean jdbcCompliant() {
-        return true;
-    }
-
-    public ConnectionPool getPool(String url) throws SQLException {
-        return (ConnectionPool) pooltable.get(url);
-    }
-
-} //class