Now the client objects are part of the published api I did some cleanup
of the javadoc comments, attached is the patch. I'll commit assuming no
objections once my derbyall tests run.

M      org\apache\derby\jdbc\ClientXADataSource.java
M      org\apache\derby\jdbc\ClientConnectionPoolDataSource.java
M      org\apache\derby\jdbc\ClientBaseDataSource.java
M      org\apache\derby\jdbc\ClientDataSource.java


- Change instance fields to be private, their api is their getter/setter
methods (removes them from the javadoc)

- remove unused constant fields, YES,NO,NOSET

- Add a getPassword() method. password is a standard data source
property and JDBC spec says all supported data source properties must
have getter and setter methods.

- Remove some unused methods

- Make methods only used within the package and intended for internal
use 'package protected', removes them from the javadoc


Still most of the methods have no comments and some of the classes don't
either. Some comments along the lines of the Embedded* JDBC objects
would be good, especially stressing these are the client api.

Also moving some code around would remove some of the public methods, or
allow them to be package protected. These are methods that are not
intended to be part of the public api. I'll submit that in a separate patch.

Another interesting issue is all the propertyKey_* fields appear in the
javadoc, though they are not part of the public api, but how they are
used requires they be public. I think it would be good to somehow fix
this, rather than having javadoc comments saying 'internal field - do
not use'.

Dan.
Index: org/apache/derby/jdbc/ClientXADataSource.java
===================================================================
--- org/apache/derby/jdbc/ClientXADataSource.java       (revision 208699)
+++ org/apache/derby/jdbc/ClientXADataSource.java       (working copy)
@@ -39,7 +39,7 @@
     }
 
     public XAConnection getXAConnection() throws SQLException {
-        return getXAConnection(user, password);
+        return getXAConnection(getUser(), getPassword());
     }
 
     public XAConnection getXAConnection(String user, String password) throws 
SQLException {
Index: org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
===================================================================
--- org/apache/derby/jdbc/ClientConnectionPoolDataSource.java   (revision 
208699)
+++ org/apache/derby/jdbc/ClientConnectionPoolDataSource.java   (working copy)
@@ -47,7 +47,7 @@
         if (dncLogWriter != null) {
             dncLogWriter.traceEntry(this, "getPooledConnection");
         }
-        PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, 
this, user, password);
+        PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, 
this, getUser(), getPassword());
         if (dncLogWriter != null) {
             dncLogWriter.traceExit(this, "getPooledConnection", 
pooledConnection);
         }
@@ -67,19 +67,6 @@
         return pooledConnection;
     }
 
-    //  method that establishes the initial physical connection using DS 
properties instead of CPDS properties.
-    public PooledConnection getPooledConnection(ClientDataSource ds, String 
user, String password) throws SQLException {
-        LogWriter dncLogWriter = 
ds.computeDncLogWriterForNewConnection("_cpds");
-        if (dncLogWriter != null) {
-            dncLogWriter.traceEntry(this, "getPooledConnection", ds, user, 
"<escaped>");
-        }
-        PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, 
ds, user, password);
-        if (dncLogWriter != null) {
-            dncLogWriter.traceExit(this, "getPooledConnection", 
pooledConnection);
-        }
-        return pooledConnection;
-    }
-
     //  method that establishes the initial physical connection
     // using DS properties instead of CPDS properties.
     private PooledConnection getPooledConnectionX(LogWriter dncLogWriter, 
ClientDataSource ds, String user, String password) throws SQLException {
Index: org/apache/derby/jdbc/ClientBaseDataSource.java
===================================================================
--- org/apache/derby/jdbc/ClientBaseDataSource.java     (revision 208699)
+++ org/apache/derby/jdbc/ClientBaseDataSource.java     (working copy)
@@ -60,7 +60,7 @@
     
//---------------------contructors/finalizers---------------------------------
 
     // This class is abstract, hide the default constructor
-    protected ClientBaseDataSource() {
+    ClientBaseDataSource() {
     }
 
     // ---------------------------- loginTimeout 
-----------------------------------
@@ -72,7 +72,7 @@
      *
      * @serial
      */
-    protected int loginTimeout = propertyDefault_loginTimeout;
+    private int loginTimeout = propertyDefault_loginTimeout;
     public final static String propertyKey_loginTimeout = "loginTimeout";
     public static final int propertyDefault_loginTimeout = 0;
 
@@ -91,7 +91,7 @@
      *
      * @see #traceLevel
      */
-    protected transient PrintWriter logWriter = null;
+    private transient PrintWriter logWriter;
 
     public synchronized void setLogWriter(PrintWriter logWriter) {
         this.logWriter = logWriter;
@@ -108,7 +108,7 @@
     // and therefore may throw an SQLException.
     //
     //
-    protected String databaseName = null;
+    private String databaseName;
     public final static String propertyKey_databaseName = "databaseName";
 
     // databaseName is not permitted in a properties object
@@ -116,7 +116,7 @@
 
     // ---------------------------- description ------------------------------
     // A description of this data source.
-    protected String description = null;
+    private String description;
     public final static String propertyKey_description = "description";
 
     // ---------------------------- dataSourceName 
-----------------------------------
@@ -125,19 +125,19 @@
     // used to name an underlying XADataSource,
     // or ConnectionPoolDataSource when pooling of connections is done.
     //
-    protected String dataSourceName = null;
+    private String dataSourceName;
     public final static String propertyKey_dataSourceName = "dataSourceName";
 
     // ---------------------------- portNumber 
-----------------------------------
     //
-    protected int portNumber = propertyDefault_portNumber;
+    private int portNumber = propertyDefault_portNumber;
     public final static int propertyDefault_portNumber = 1527;
     public final static String propertyKey_portNumber = "portNumber";
 
     // ---------------------------- serverName 
-----------------------------------
     //
     //
-    protected String serverName = null;
+    private String serverName;
     public final static String propertyKey_serverName = "serverName";
 
     // serverName is not permitted in a properties object
@@ -153,7 +153,7 @@
     // Each data source implementation subclass will maintain it's own 
<code>password</code> property.
     // This password property may or may not be declared transient, and 
therefore may be serialized
     // to a file in clear-text, care must taken by the user to prevent 
security breaches.
-    protected String user = null;
+    private String user;
     public final static String propertyKey_user = "user";
     public final static String propertyDefault_user = "APP";
 
@@ -165,11 +165,7 @@
     public final static int HOLD_CURSORS_OVER_COMMIT = 1; // this matches jdbc 
3 ResultSet.HOLD_CURSORS_OVER_COMMIT
     public final static int CLOSE_CURSORS_AT_COMMIT = 2;  // this matches jdbc 
3 ResultSet.CLOSE_CURSORS_AT_COMMIT
 
-    public final static int NOT_SET = 0; // 0 means not set.
-    public final static int YES = 1; // ="yes" as property string
-    public final static int NO = 2;  // ="no" as property string
 
-
     // ---------------------------- securityMechanism 
-----------------------------------
     //
     // The source security mechanism to use when connecting to this data 
source.
@@ -193,7 +189,7 @@
     // Both user and password need to be set for all security mechanism except 
USER_ONLY_SECURITY
     // When using USER_ONLY_SECURITY, only the user property needs to be 
specified.
     //
-    protected short securityMechanism = propertyDefault_securityMechanism;
+    private short securityMechanism = propertyDefault_securityMechanism;
     // TODO default  should be  USER_ONLY_SECURITY. Change when working on
     // Network Server
     //  public final static short propertyDefault_securityMechanism = (short)
@@ -226,7 +222,7 @@
 
     // ---------------------------- getServerMessageTextOnGetMessage 
-----------------------------------
     //
-    protected boolean retrieveMessageText = 
propertyDefault_retrieveMessageText;
+    private boolean retrieveMessageText = propertyDefault_retrieveMessageText;
     public final static boolean propertyDefault_retrieveMessageText = true;
     public final static String propertyKey_retrieveMessageText = 
"retrieveMessageText";
 
@@ -238,7 +234,7 @@
 
     // ---------------------------- traceFile 
-----------------------------------
     //
-    protected String traceFile = null;
+    private String traceFile;
     public final static String propertyKey_traceFile = "traceFile";
 
     public static String getTraceFile(Properties properties) {
@@ -249,7 +245,7 @@
     // For the suffix of the trace file when traceDirectory is enabled.
     private transient int traceFileSuffixIndex_ = 0;
     //
-    protected String traceDirectory = null;
+    private String traceDirectory;
     public final static String propertyKey_traceDirectory = "traceDirectory";
 
     public static String getTraceDirectory(Properties properties) {
@@ -258,7 +254,7 @@
 
     // ---------------------------- traceFileAppend 
-----------------------------------
     //
-    protected boolean traceFileAppend = propertyDefault_traceFileAppend;
+    private boolean traceFileAppend = propertyDefault_traceFileAppend;
     public final static boolean propertyDefault_traceFileAppend = false;
     public final static String propertyKey_traceFileAppend = "traceFileAppend";
 
@@ -278,11 +274,15 @@
         return properties.getProperty("password");
     }
 
-    protected String password = null;
+    private String password;
 
-    synchronized public void setPassword(String password) {
+    synchronized public final void setPassword(String password) {
         this.password = password;
     }
+    
+    public final String getPassword() {
+       return password;
+    }
 
     //------------------------ interface methods 
---------------------------------
 
@@ -495,14 +495,14 @@
     // If neither traceFile nor jdbc logWriter are set, then null is returned.
     // logWriterInUseSuffix used only for trace directories to indicate whether
     // log writer is use is from xads, cpds, sds, ds, driver, config, reset.
-    public LogWriter computeDncLogWriterForNewConnection(String 
logWriterInUseSuffix) throws SqlException {
+    LogWriter computeDncLogWriterForNewConnection(String logWriterInUseSuffix) 
throws SqlException {
         return computeDncLogWriterForNewConnection(logWriter, traceDirectory, 
traceFile, traceFileAppend, traceLevel, logWriterInUseSuffix, 
traceFileSuffixIndex_++);
     }
 
     // Called on for connection requests.
     // The java.io.PrintWriter overrides the traceFile setting.
     // If neither traceFile, nor logWriter, nor traceDirectory are set, then 
null is returned.
-    static public LogWriter computeDncLogWriterForNewConnection(PrintWriter 
logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, 
int traceLevel, String logWriterInUseSuffix, int traceFileSuffixIndex) throws 
SqlException {
+    static LogWriter computeDncLogWriterForNewConnection(PrintWriter 
logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, 
int traceLevel, String logWriterInUseSuffix, int traceFileSuffixIndex) throws 
SqlException {
         int globaltraceFileSuffixIndex = 
Configuration.traceFileSuffixIndex__++;
 
         // compute regular dnc log writer if there is any
@@ -779,7 +779,7 @@
         return getUpgradedSecurityMechanism(securityMechanism, password);
     }
 
-    protected String connectionAttributes = "";
+    private String connectionAttributes = "";
 
     /**
      * Set this property to pass in more Derby specific connection URL 
attributes.
@@ -820,7 +820,7 @@
     public final static int propertyDefault_traceLevel = TRACE_ALL;
     public final static String propertyKey_traceLevel = "traceLevel";
 
-    protected int traceLevel = propertyDefault_traceLevel;
+    private int traceLevel = propertyDefault_traceLevel;
 
     public static int getTraceLevel(Properties properties) {
         String traceLevelString = 
properties.getProperty(propertyKey_traceLevel);
@@ -871,7 +871,7 @@
      * The dataSource keeps individual fields for the values that are relevant 
to the client. These need to be updated
      * when set connection attributes is called.
      */
-    protected void updateDataSourceValues(Properties prop) {
+    void updateDataSourceValues(Properties prop) {
         if (prop.containsKey(propertyKey_user)) {
             setUser(getUser(prop));
         }
Index: org/apache/derby/jdbc/ClientDataSource.java
===================================================================
--- org/apache/derby/jdbc/ClientDataSource.java (revision 208699)
+++ org/apache/derby/jdbc/ClientDataSource.java (working copy)
@@ -132,7 +132,7 @@
      * @throws java.sql.SQLException if a database-access error occurs.
      */
     public Connection getConnection() throws SQLException {
-        return getConnection(user, password);
+        return getConnection(getUser(), getPassword());
     }
 
     /**
@@ -152,7 +152,7 @@
         // This log writer will be passed to the agent constructor.
 
         LogWriter dncLogWriter = 
super.computeDncLogWriterForNewConnection("_sds");
-        updateDataSourceValues(tokenizeAttributes(connectionAttributes, null));
+        updateDataSourceValues(tokenizeAttributes(getConnectionAttributes(), 
null));
         return new NetConnection((NetLogWriter) dncLogWriter, user, password, 
this, -1, false);
     }
 

Reply via email to