You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/03/25 02:38:38 UTC

svn commit: r388687 - in /db/derby/code/trunk/java: client/org/apache/derby/jdbc/ engine/org/apache/derby/iapi/reference/ shared/org/apache/derby/shared/common/reference/

Author: djd
Date: Fri Mar 24 17:38:37 2006
New Revision: 388687

URL: http://svn.apache.org/viewcvs?rev=388687&view=rev
Log:
DERBY-446 (partial) Copy Attribute.java to the java/shared reference area and add in constants
for the client JDBC attributes. Change the client code to use these constants as preparation to
removing these constants from the user visible classes.

Added:
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/Attribute.java   (with props)
Modified:
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?rev=388687&r1=388686&r2=388687&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java Fri Mar 24 17:38:37 2006
@@ -41,6 +41,7 @@
 import org.apache.derby.client.net.NetConfiguration;
 import org.apache.derby.client.net.NetLogWriter;
 import org.apache.derby.client.ClientDataSourceFactory;
+import org.apache.derby.shared.common.reference.Attribute;
 
 /**
  * Base class for client-side DataSource implementations.
@@ -188,7 +189,7 @@
     public final static String propertyDefault_user = "APP";
 
     public static String getUser(Properties properties) {
-        String userString = properties.getProperty(propertyKey_user);
+        String userString = properties.getProperty(Attribute.USERNAME_ATTR);
         return parseString(userString, propertyDefault_user);
     }
 
@@ -251,7 +252,7 @@
      */
     public static short getSecurityMechanism(Properties properties) {
         short secmec;
-        String securityMechanismString = properties.getProperty(propertyKey_securityMechanism);
+        String securityMechanismString = properties.getProperty(Attribute.CLIENT_SECURITY_MECHANISM);
         if ( securityMechanismString != null )
         {
             // security mechanism has been set, do not override, but instead return
@@ -265,7 +266,7 @@
             // properties. Hence, do an upgrade of security mechanism if possible
             // The logic for upgrade of security mechanism uses information about 
             // if password is available or not, so pass this information also.
-            String passwordString = properties.getProperty(propertyKey_password);
+            String passwordString = properties.getProperty(Attribute.PASSWORD_ATTR);
             secmec = getUpgradedSecurityMechanism(passwordString);
         }
         return secmec;
@@ -313,7 +314,7 @@
 
 
     public static boolean getRetrieveMessageText(Properties properties) {
-        String retrieveMessageTextString = properties.getProperty(propertyKey_retrieveMessageText);
+        String retrieveMessageTextString = properties.getProperty(Attribute.CLIENT_RETIEVE_MESSAGE_TEXT);
         return parseBoolean(retrieveMessageTextString, propertyDefault_retrieveMessageText);
     }
 
@@ -323,7 +324,7 @@
     public final static String propertyKey_traceFile = "traceFile";
 
     public static String getTraceFile(Properties properties) {
-        return properties.getProperty(propertyKey_traceFile);
+        return properties.getProperty(Attribute.CLIENT_TRACE_FILE);
     }
 
     // ---------------------------- traceDirectory -----------------------------------
@@ -334,7 +335,7 @@
     public final static String propertyKey_traceDirectory = "traceDirectory";
 
     public static String getTraceDirectory(Properties properties) {
-        return properties.getProperty(propertyKey_traceDirectory);
+        return properties.getProperty(Attribute.CLIENT_TRACE_DIRECTORY);
     }
 
     // ---------------------------- traceFileAppend -----------------------------------
@@ -344,7 +345,7 @@
     public final static String propertyKey_traceFileAppend = "traceFileAppend";
 
     public static boolean getTraceFileAppend(Properties properties) {
-        String traceFileAppendString = properties.getProperty(propertyKey_traceFileAppend);
+        String traceFileAppendString = properties.getProperty(Attribute.CLIENT_TRACE_APPEND);
         return parseBoolean(traceFileAppendString, propertyDefault_traceFileAppend);
     }
 
@@ -670,7 +671,7 @@
             // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
             throw new SqlException(null, e, "Invalid attribute syntax: " + attributeString);
         }
-        checkBoolean(augmentedProperties, propertyKey_retrieveMessageText);
+        checkBoolean(augmentedProperties, Attribute.CLIENT_RETIEVE_MESSAGE_TEXT);
         return augmentedProperties;
 
     }
@@ -936,25 +937,25 @@
             return;
         }
         
-        if (prop.containsKey(propertyKey_user)) {
+        if (prop.containsKey(Attribute.USERNAME_ATTR)) {
             setUser(getUser(prop));
         }
-        if (prop.containsKey(propertyKey_securityMechanism)) {
+        if (prop.containsKey(Attribute.CLIENT_SECURITY_MECHANISM)) {
             setSecurityMechanism(getSecurityMechanism(prop));
         }
-        if (prop.containsKey(propertyKey_traceFile)) {
+        if (prop.containsKey(Attribute.CLIENT_TRACE_FILE)) {
             setTraceFile(getTraceFile(prop));
         }
-        if (prop.containsKey(propertyKey_traceDirectory)) {
+        if (prop.containsKey(Attribute.CLIENT_TRACE_DIRECTORY)) {
             setTraceDirectory(getTraceDirectory(prop));
         }
-        if (prop.containsKey(propertyKey_traceFileAppend)) {
+        if (prop.containsKey(Attribute.CLIENT_TRACE_APPEND)) {
             setTraceFileAppend(getTraceFileAppend(prop));
         }
-        if (prop.containsKey(propertyKey_securityMechanism)) {
+        if (prop.containsKey(Attribute.CLIENT_SECURITY_MECHANISM)) {
             setSecurityMechanism(getSecurityMechanism(prop));
         }
-        if (prop.containsKey(propertyKey_retrieveMessageText)) {
+        if (prop.containsKey(Attribute.CLIENT_RETIEVE_MESSAGE_TEXT)) {
             setRetrieveMessageText(getRetrieveMessageText(prop));
         }
     }

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java?rev=388687&r1=388686&r2=388687&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java Fri Mar 24 17:38:37 2006
@@ -31,6 +31,7 @@
 import org.apache.derby.client.am.ClientJDBCObjectFactory;
 import org.apache.derby.client.net.ClientJDBCObjectFactoryImpl;
 import org.apache.derby.client.resources.ResourceKeys;
+import org.apache.derby.shared.common.reference.Attribute;
 
 
 public class ClientDriver implements java.sql.Driver {
@@ -164,8 +165,8 @@
 		for (Enumeration keys = augmentedProperties.keys(); keys.hasMoreElements() ;)
 		{
 			String key = (String) keys.nextElement();
-			if (key.equals(ClientDataSource.propertyKey_user) || 
-				key.equals(ClientDataSource.propertyKey_password))
+			if (key.equals(Attribute.USERNAME_ATTR) || 
+				key.equals(Attribute.PASSWORD_ATTR))
 				continue;
 			longDatabase.append(";" + key + "=" + augmentedProperties.getProperty(key));
 		}
@@ -197,12 +198,12 @@
         }
 
         driverPropertyInfo[0] =
-                new java.sql.DriverPropertyInfo(ClientDataSource.propertyKey_user,
-                        properties.getProperty(ClientDataSource.propertyKey_user, ClientDataSource.propertyDefault_user));
+                new java.sql.DriverPropertyInfo(Attribute.USERNAME_ATTR,
+                        properties.getProperty(Attribute.USERNAME_ATTR, ClientDataSource.propertyDefault_user));
 
         driverPropertyInfo[1] =
-                new java.sql.DriverPropertyInfo(ClientDataSource.propertyKey_password,
-                        properties.getProperty(ClientDataSource.propertyKey_password));
+                new java.sql.DriverPropertyInfo(Attribute.PASSWORD_ATTR,
+                        properties.getProperty(Attribute.PASSWORD_ATTR));
 
         driverPropertyInfo[0].description =
                 ResourceUtilities.getResource(ResourceKeys.propertyDescription__user);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java?rev=388687&r1=388686&r2=388687&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java Fri Mar 24 17:38:37 2006
@@ -39,6 +39,15 @@
 	<P>
 	This class has no methods, all it contains are String's which by
 	are public, static and final since they are declared in an interface.
+    
+    <P>
+    At some point this class should be replaced by
+    org.apache.derby.shared.common.reference.Attribute.
+    The issue is that this class is used by ij to check attributes,
+    ij uses reflection on this class to get the list of valid attributes.
+    The expanded class in shared has the client attributes as well.
+    Ideally ij would work of an explicit list of attributes and not
+    infer the set from reflection. See DERBY-1151
 */
 
 public interface Attribute {

Added: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/Attribute.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/Attribute.java?rev=388687&view=auto
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/Attribute.java (added)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/Attribute.java Fri Mar 24 17:38:37 2006
@@ -0,0 +1,210 @@
+/*
+
+ Derby - Class org.apache.derby.shared.common.reference.Attribute
+
+ Copyright 1999, 2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed 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.derby.shared.common.reference;
+
+/**
+ * List of all connection (JDBC) attributes by the system.
+ * 
+ * 
+ * <P>
+ * This class exists for two reasons
+ * <Ol>
+ * <LI> To act as the internal documentation for the attributes.
+ * <LI> To remove the need to declare a java static field for the attributes
+ * name in the protocol/implementation class. This reduces the footprint as the
+ * string is final and thus can be included simply as a String constant pool
+ * entry.
+ * </OL>
+ * <P>
+ * This class should not be shipped with the product.
+ * 
+ * <P>
+ * This class has no methods, all it contains are String's which by are public,
+ * static and final since they are declared in an interface.
+ */
+
+public interface Attribute {
+
+    /**
+     * Not an attribute but the root for the JDBC URL that Derby supports.
+     */
+    String PROTOCOL = "jdbc:derby:";
+
+    /**
+     * The SQLJ protocol for getting the default connection for server side jdbc
+     */
+    String SQLJ_NESTED = "jdbc:default:connection";
+
+    // Network Protocols. These need to be rejected by the embedded driver.
+
+    /**
+     * The protocol for Derby Network Client
+     */
+    String DNC_PROTOCOL = "jdbc:derby://";
+
+    /**
+     * The protocol for the IBM Universal JDBC Driver
+     * 
+     */
+    String JCC_PROTOCOL = "jdbc:derby:net:";
+
+    /**
+     * Attribute name to encrypt the database on disk. If set to true, all user
+     * data is stored encrypted on disk.
+     */
+    String DATA_ENCRYPTION = "dataEncryption";
+
+    /**
+     * If dataEncryption is true, use this attribute to pass in the secret key.
+     * The secret key must be at least 8 characters long. This key must not be
+     * stored persistently in cleartext anywhere.
+     */
+
+    String BOOT_PASSWORD = "bootPassword";
+
+    /**
+     * The attribute that is used for the database name, from the JDBC notion of
+     * jdbc:<subprotocol>:<subname>
+     */
+    String DBNAME_ATTR = "databaseName";
+
+    /**
+     * The attribute that is used to request a shutdown.
+     */
+    String SHUTDOWN_ATTR = "shutdown";
+
+    /**
+     * The attribute that is used to request a database create.
+     */
+    String CREATE_ATTR = "create";
+
+    /**
+     * The attribute that is used to set the user name.
+     */
+    String USERNAME_ATTR = "user";
+
+    /**
+     * The attribute that is used to set the user password.
+     */
+    String PASSWORD_ATTR = "password";
+
+    /**
+     * The attribute that is used to set the connection's DRDA ID.
+     */
+    String DRDAID_ATTR = "drdaID";
+
+    /**
+     * The attribute that is used to allow upgrade.
+     */
+    String UPGRADE_ATTR = "upgrade";
+
+    /**
+     * Put the log on a different device.
+     */
+    String LOG_DEVICE = "logDevice";
+
+    /**
+     * Set the territory for the database.
+     */
+    String TERRITORY = "territory";
+
+    /**
+     * Set the collation sequence of the database, currently on IDENTITY will be
+     * supported (strings will sort according to binary comparison).
+     */
+    String COLLATE = "collate";
+
+    /**
+     * Attribute for encrypting a database. Specifies the cryptographic services
+     * provider.
+     */
+    String CRYPTO_PROVIDER = "encryptionProvider";
+
+    /**
+     * Attribute for encrypting a database. Specifies the cryptographic
+     * algorithm.
+     */
+    String CRYPTO_ALGORITHM = "encryptionAlgorithm";
+
+    /**
+     * Attribute for encrypting a database. Specifies the key length in bytes
+     * for the specified cryptographic algorithm.
+     */
+    String CRYPTO_KEY_LENGTH = "encryptionKeyLength";
+
+    /**
+     * Attribute for encrypting a database. Specifies the actual key. When this
+     * is specified all the supplied crypto information is stored external to
+     * the database, ie by the application.
+     */
+    String CRYPTO_EXTERNAL_KEY = "encryptionKey";
+
+    /**
+     * This attribute is used to request to create a database from backup. This
+     * will throw error if a database with same already exists at the location
+     * where we tring to create.
+     */
+    String CREATE_FROM = "createFrom";
+
+    /**
+     * This attribute is used to request a database restore from backup. It must
+     * be used only when the active database is corrupted, because it will
+     * cleanup the existing database and replace it from the backup.
+     */
+    String RESTORE_FROM = "restoreFrom";
+
+    /**
+     * The attribute that is used to request a roll-forward recovery of the
+     * database.
+     */
+    String ROLL_FORWARD_RECOVERY_FROM = "rollForwardRecoveryFrom";
+
+    /**
+     * securityMechanism sets the mechanism for transmitting the user name and
+     * password from the client. Client driver attribute.
+     */
+    String CLIENT_SECURITY_MECHANISM = "securityMechanism";
+
+    /**
+     * traceFile sets the client side trace file. Client driver attribute.
+     */
+    String CLIENT_TRACE_FILE = "traceFile";
+
+    /**
+     * traceDirectory sets the client side trace directory.
+     * Client driver attribute.
+     */
+    String CLIENT_TRACE_DIRECTORY = "traceDirectory";
+    
+    /**
+     * traceFileAppend.
+     * Client driver attribute.
+     */
+    String CLIENT_TRACE_APPEND = "traceFileAppend";
+    
+    /**
+     * retrieveMessageText.
+     * Client driver attribute.
+     */    
+    String CLIENT_RETIEVE_MESSAGE_TEXT = "retrieveMessageText";
+}
+
+

Propchange: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/Attribute.java
------------------------------------------------------------------------------
    svn:eol-style = native