harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548961 - in /harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java: java/sql/Wrapper.java javax/sql/CommonDataSource.java javax/sql/ConnectionPoolDataSource.java javax/sql/DataSource.java javax/sql/XADataSource.java
Date Wed, 20 Jun 2007 07:00:26 GMT
Author: tonywu
Date: Wed Jun 20 00:00:25 2007
New Revision: 548961

URL: http://svn.apache.org/viewvc?view=rev&rev=548961
Log:
Apply patch HARMONY-4240 ([classlib][sql][java6] new interface java.sql.Wrapper and javax.sql.CommonDataSource)

Added:
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Wrapper.java
  (with props)
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/CommonDataSource.java
  (with props)
Modified:
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/DataSource.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/XADataSource.java

Added: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Wrapper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Wrapper.java?view=auto&rev=548961
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Wrapper.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Wrapper.java
Wed Jun 20 00:00:25 2007
@@ -0,0 +1,52 @@
+/* 
+ * 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 java.sql;
+
+/**
+ * This class is an actual usage of the wrapper pattern for JDBC classes.
+ * Developers can get the delegate instance when the instance may be a proxy
+ * class.
+ * 
+ * @since 1.6
+ */
+public interface Wrapper {
+
+	/**
+	 * Answers an object that implements the given interface. If the caller is
+	 * not a wrapper, a SQLException will be thrown.
+	 * 
+	 * @param iface -
+	 *            the class that defines the interface
+	 * @return - an object that implements the interface
+	 * @throws SQLException -
+	 *             if there is no object implementing the specific interface
+	 */
+	<T> T unwrap(Class<T> iface) throws SQLException;
+
+	/**
+	 * If the caller is a wrapper of the class or implements the given
+	 * interface, the methods return false and vice versa.
+	 * 
+	 * @param iface -
+	 *            the class that defines the interface
+	 * @return - true if the instance implements the interface
+	 * @throws SQLException -
+	 *             when an error occurs when judges the object
+	 */
+	boolean isWrapperFor(Class<?> iface) throws SQLException;
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Wrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/CommonDataSource.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/CommonDataSource.java?view=auto&rev=548961
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/CommonDataSource.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/CommonDataSource.java
Wed Jun 20 00:00:25 2007
@@ -0,0 +1,72 @@
+/* 
+ * 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 javax.sql;
+
+import java.io.PrintWriter;
+import java.sql.SQLException;
+
+/**
+ * Interface that defines the methods which are common between DataSource,
+ * XADataSource and ConnectionPoolDataSource.	
+ * 
+ * @since 1.6
+ */
+public interface CommonDataSource {
+
+    /**
+     * While attempting to connect to a database, this method get the maximum
+     * time in seconds that this data source can wait.
+     * 
+     * @return An integer value to indicate the maximum time.
+     * @throws SQLException
+     *             An exception threw when a data base access error occurs.
+     */
+    public int getLoginTimeout() throws SQLException;
+
+    /**
+     * Retrieves a log writer which is a character output stream to which all
+     * logging and tracing messages for this data source will be printed.
+     * 
+     * @return The PrintWriter object for this DataSource.
+     * @throws SQLException
+     *             An exception threw when a data base access error occurs.
+     */
+    PrintWriter getLogWriter() throws SQLException;
+
+    /**
+     * While attempting to connect to a database, this method set the maximum
+     * time in seconds that this data source can wait.
+     * 
+     * @param seconds
+     *            An integer value to indicate the maximum time.
+     * @throws SQLException
+     *             An exception threw when a data base access error occurs.
+     */
+    void setLoginTimeout(int seconds) throws SQLException;
+
+    /**
+     * Set a log writer which is a character output stream to which all logging
+     * and tracing messages for this data source will be printed.
+     * 
+     * @param out
+     *            The PrintWriter object for this DataSource.
+     * @throws SQLException
+     *             An exception threw when a data base access error occurs.
+     */
+    void setLogWriter(PrintWriter out) throws SQLException;
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/CommonDataSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java?view=diff&rev=548961&r1=548960&r2=548961
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java
Wed Jun 20 00:00:25 2007
@@ -18,7 +18,6 @@
 package javax.sql;
 
 import java.sql.SQLException;
-import java.io.PrintWriter;
 
 /**
  * An interface for the creation of PooledConnection objects. Used internally
@@ -28,96 +27,33 @@
  * registered with a JNDI naming service directory and is retrieved from there
  * by name.
  */
-public interface ConnectionPoolDataSource {
+public interface ConnectionPoolDataSource extends CommonDataSource {
 
-    /**
-     * Gets the Login Timeout value for this ConnectionPoolDataSource. The Login
-     * Timeout is the maximum time in seconds that the ConnectionPoolDataSource
-     * will wait when opening a connection to a database. A Timeout value of 0
-     * implies either the system default timeout value (if there is one) or that
-     * there is no timeout. The default value for the Login Timeout is 0.
-     * 
-     * @return the Login Timeout value in seconds.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public int getLoginTimeout() throws SQLException;
-
-    /**
-     * Gets the Log Writer for this ConnectionPoolDataSource.
-     * <p>
-     * The Log Writer is a stream to which all log and trace messages are sent
-     * from this ConnectionPoolDataSource. The Log Writer can be null, in which
-     * case, log and trace capture is disabled. The default value for the Log
-     * Writer when an ConnectionPoolDataSource is created is null. Note that the
-     * Log Writer for an ConnectionPoolDataSource is not the same as the Log
-     * Writer used by a <code>DriverManager</code>.
-     * 
-     * @return a PrintWriter which is the Log Writer for this
-     *         ConnectionPoolDataSource. Can be null, in which case log writing
-     *         is disabled for this ConnectionPoolDataSource.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public PrintWriter getLogWriter() throws SQLException;
-
-    /**
-     * Create a connection to a database which can then be used as a pooled
-     * connection.
-     * 
-     * @return a PooledConnection which represents the connection to the
-     *         database
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public PooledConnection getPooledConnection() throws SQLException;
-
-    /**
-     * Create a connection to a database, using a supplied Username and
-     * Password, which can then be used as a pooled connection.
-     * 
-     * @param theUser
-     *            a String containing a User Name for the database
-     * @param thePassword
-     *            a String containing the Password for the user identified by
-     *            <code>theUser</code>
-     * @return a PooledConnection which represents the connection to the
-     *         database
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public PooledConnection getPooledConnection(String theUser,
-            String thePassword) throws SQLException;
-
-    /**
-     * Sets the Login Timeout value for this ConnectionPoolDataSource. The Login
-     * Timeout is the maximum time in seconds that the ConnectionPoolDataSource
-     * will wait when opening a connection to a database. A Timeout value of 0
-     * implies either the system default timeout value (if there is one) or that
-     * there is no timeout. The default value for the Login Timeout is 0.
-     * 
-     * @param theTimeout
-     *            the new Login Timeout value in seconds.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public void setLoginTimeout(int theTimeout) throws SQLException;
-
-    /**
-     * Sets the Log Writer for this ConnectionPoolDataSource.
-     * <p>
-     * The Log Writer is a stream to which all log and trace messages are sent
-     * from this ConnectionPoolDataSource. The Log Writer can be null, in which
-     * case, log and trace capture is disabled. The default value for the Log
-     * Writer when an ConnectionPoolDataSource is created is null. Note that the
-     * Log Writer for an ConnectionPoolDataSource is not the same as the Log
-     * Writer used by a <code>DriverManager</code>.
-     * 
-     * @param theWriter
-     *            a PrintWriter to use as the Log Writer for this
-     *            ConnectionPoolDataSource.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public void setLogWriter(PrintWriter theWriter) throws SQLException;
+	/**
+	 * Create a connection to a database which can then be used as a pooled
+	 * connection.
+	 * 
+	 * @return a PooledConnection which represents the connection to the
+	 *         database
+	 * @throws SQLException
+	 *             if there is a problem accessing the database.
+	 */
+	public PooledConnection getPooledConnection() throws SQLException;
+
+	/**
+	 * Create a connection to a database, using a supplied Username and
+	 * Password, which can then be used as a pooled connection.
+	 * 
+	 * @param theUser
+	 *            a String containing a User Name for the database
+	 * @param thePassword
+	 *            a String containing the Password for the user identified by
+	 *            <code>theUser</code>
+	 * @return a PooledConnection which represents the connection to the
+	 *         database
+	 * @throws SQLException
+	 *             if there is a problem accessing the database.
+	 */
+	public PooledConnection getPooledConnection(String theUser,
+			String thePassword) throws SQLException;
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/DataSource.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/DataSource.java?view=diff&rev=548961&r1=548960&r2=548961
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/DataSource.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/DataSource.java
Wed Jun 20 00:00:25 2007
@@ -17,9 +17,9 @@
 
 package javax.sql;
 
-import java.sql.SQLException;
 import java.sql.Connection;
-import java.io.PrintWriter;
+import java.sql.SQLException;
+import java.sql.Wrapper;
 
 /**
  * An interface for the creation of Connection objects which represent a
@@ -50,7 +50,7 @@
  * loaded via a JNDI lookup process. A driver loaded in this way does not
  * register itself with the <code>DriverManager</code>.
  */
-public interface DataSource {
+public interface DataSource extends CommonDataSource, Wrapper{
 
     /**
      * Creates a connection to the database represented by this DataSource.
@@ -75,64 +75,5 @@
      *             if there is a problem accessing the database.
      */
     public Connection getConnection(String theUsername, String thePassword)
-            throws SQLException;
-
-    /**
-     * Gets the Login Timeout value for this DataSource. The Login Timeout is
-     * the maximum time in seconds that the DataSource will wait when opening a
-     * connection to a database. A Timeout value of 0 implies either the system
-     * default timeout value (if there is one) or that there is no timeout. The
-     * default value for the Login Timeout is 0.
-     * 
-     * @return the Login Timeout value in seconds.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public int getLoginTimeout() throws SQLException;
-
-    /**
-     * Gets the Log Writer for this DataSource.
-     * <p>
-     * The Log Writer is a stream to which all log and trace messages are sent
-     * from this DataSource. The Log Writer can be null, in which case, log and
-     * trace capture is disabled. The default value for the Log Writer when an
-     * DataSource is created is null. Note that the Log Writer for an DataSource
-     * is not the same as the Log Writer used by a <code>DriverManager</code>.
-     * 
-     * @return a PrintWriter which is the Log Writer for this DataSource. Can be
-     *         null, in which case log writing is disabled for this DataSource.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public PrintWriter getLogWriter() throws SQLException;
-
-    /**
-     * Sets the Login Timeout value for this DataSource. The Login Timeout is
-     * the maximum time in seconds that the DataSource will wait when opening a
-     * connection to a database. A Timeout value of 0 implies either the system
-     * default timeout value (if there is one) or that there is no timeout. The
-     * default value for the Login Timeout is 0.
-     * 
-     * @param theTimeout
-     *            the new Login Timeout value in seconds.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public void setLoginTimeout(int theTimeout) throws SQLException;
-
-    /**
-     * Sets the Log Writer for this DataSource.
-     * <p>
-     * The Log Writer is a stream to which all log and trace messages are sent
-     * from this DataSource. The Log Writer can be null, in which case, log and
-     * trace capture is disabled. The default value for the Log Writer when an
-     * DataSource is created is null. Note that the Log Writer for an DataSource
-     * is not the same as the Log Writer used by a <code>DriverManager</code>.
-     * 
-     * @param theWriter
-     *            a PrintWriter to use as the Log Writer for this DataSource.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public void setLogWriter(PrintWriter theWriter) throws SQLException;
+            throws SQLException;    
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/XADataSource.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/XADataSource.java?view=diff&rev=548961&r1=548960&r2=548961
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/XADataSource.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/XADataSource.java
Wed Jun 20 00:00:25 2007
@@ -18,7 +18,6 @@
 package javax.sql;
 
 import java.sql.SQLException;
-import java.io.PrintWriter;
 
 /**
  * An interface for the creation of XAConnection objects. Used internally within
@@ -27,51 +26,7 @@
  * A class which implements the XADataSource interface is typically registered
  * with a JNDI naming service directory and is retrieved from there by name.
  */
-public interface XADataSource {
-
-    /**
-     * Gets the Login Timeout value for this XADataSource. The Login Timeout is
-     * the maximum time in seconds that the XADataSource will wait when opening
-     * a connection to a database. A Timeout value of 0 implies either the
-     * system default timeout value (if there is one) or that there is no
-     * timeout. The default value for the Login Timeout is 0.
-     * 
-     * @return the Login Timeout value in seconds.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public int getLoginTimeout() throws SQLException;
-
-    /**
-     * Sets the Login Timeout value for this XADataSource. The Login Timeout is
-     * the maximum time in seconds that the XADataSource will wait when opening
-     * a connection to a database. A Timeout value of 0 implies either the
-     * system default timeout value (if there is one) or that there is no
-     * timeout. The default value for the Login Timeout is 0.
-     * 
-     * @param theTimeout
-     *            the new Login Timeout value in seconds.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public void setLoginTimeout(int theTimeout) throws SQLException;
-
-    /**
-     * Gets the Log Writer for this XADataSource.
-     * <p>
-     * The Log Writer is a stream to which all log and trace messages are sent
-     * from this XADataSource. The Log Writer can be null, in which case, log
-     * and trace capture is disabled. The default value for the Log Writer when
-     * an XADataSource is created is null. Note that the Log Writer for an
-     * XADataSource is not the same as the Log Writer used by a
-     * <code>DriverManager</code>.
-     * 
-     * @return a PrintWriter which is the Log Writer for this XADataSource. Can
-     *         be null, in which case log writing is disabled for this
-     *         XADataSource.
-     * @throws SQLException
-     */
-    public PrintWriter getLogWriter() throws SQLException;
+public interface XADataSource extends CommonDataSource {
 
     /**
      * Create a connection to a database which can then be used in a distributed
@@ -100,21 +55,4 @@
      */
     public XAConnection getXAConnection(String theUser, String thePassword)
             throws SQLException;
-
-    /**
-     * Sets the Log Writer for this XADataSource.
-     * <p>
-     * The Log Writer is a stream to which all log and trace messages are sent
-     * from this XADataSource. The Log Writer can be null, in which case, log
-     * and trace capture is disabled. The default value for the Log Writer when
-     * an XADataSource is created is null. Note that the Log Writer for an
-     * XADataSource is not the same as the Log Writer used by a
-     * <code>DriverManager</code>.
-     * 
-     * @param theWriter
-     *            a PrintWriter to use as the Log Writer for this XADataSource.
-     * @throws SQLException
-     *             if there is a problem accessing the database.
-     */
-    public void setLogWriter(PrintWriter theWriter) throws SQLException;
 }



Mime
View raw message