You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by th...@apache.org on 2008/12/17 14:31:12 UTC

svn commit: r727376 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java

Author: thomasm
Date: Wed Dec 17 05:31:10 2008
New Revision: 727376

URL: http://svn.apache.org/viewvc?rev=727376&view=rev
Log:
JCR-1366 DbDataStore: new setting schemaObjectPrefix (compatible with bundle PM)

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java?rev=727376&r1=727375&r2=727376&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java Wed Dec 17 05:31:10 2008
@@ -63,7 +63,8 @@
  *     <param name="{@link #setMinRecordLength(int) minRecordLength}" value="1024"/>
  *     <param name="{@link #setMaxConnections(int) maxConnections}" value="2"/>
  *     <param name="{@link #setCopyWhenReading(boolean) copyWhenReading}" value="true"/>
- *     <param name="{@link #setTablePrefix(int) tablePrefix}" value=""/>
+ *     <param name="{@link #setTablePrefix(String) tablePrefix}" value=""/>
+ *     <param name="{@link #setSchemaObjectPrefix(String) schemaObjectPrefix}" value=""/>
  * &lt/DataStore>
  * </pre>
  * <p>
@@ -185,11 +186,16 @@
     protected String tablePrefix = "";
 
     /**
+     * The prefix of the table names. By default it is empty.
+     */
+    protected String schemaObjectPrefix = "";
+
+    /**
      * This is the property 'table'
      * in the [databaseType].properties file, initialized with the default value.
      */
     protected String tableSQL = "DATASTORE";
-
+    
     /**
      * This is the property 'createTable'
      * in the [databaseType].properties file, initialized with the default value.
@@ -541,7 +547,7 @@
             DatabaseMetaData meta = conn.getConnection().getMetaData();
             log.info("Using JDBC driver " + meta.getDriverName() + " " + meta.getDriverVersion());
             meta.getDriverVersion();
-            ResultSet rs = meta.getTables(null, null, tableSQL, null);
+            ResultSet rs = meta.getTables(null, null, schemaObjectPrefix + tableSQL, null);
             boolean exists = rs.next();
             rs.close();
             if (!exists) {
@@ -550,7 +556,7 @@
             putBack(conn);
         } catch (Exception e) {
             throw convert("Can not init data store, driver=" + driver + " url=" + url + " user=" + user + 
-                    " tableSQL=" + tableSQL + " createTableSQL=" + createTableSQL, e);
+                    " schemaObjectPrefix=" + schemaObjectPrefix + " tableSQL=" + tableSQL + " createTableSQL=" + createTableSQL, e);
         }
     }
 
@@ -624,7 +630,7 @@
     /**
      * Get the expanded property value. The following placeholders are supported:
      * ${table}: the table name (the default is DATASTORE) and
-     * ${tablePrefix}: the prefix as set in the configuration (empty by default).
+     * ${tablePrefix}: tablePrefix plus schemaObjectPrefix as set in the configuration 
      *
      * @param prop the properties object
      * @param key the key
@@ -634,7 +640,7 @@
     protected String getProperty(Properties prop, String key, String defaultValue) {
         String sql = prop.getProperty(key, defaultValue);
         sql = Text.replace(sql, "${table}", tableSQL).trim();
-        sql = Text.replace(sql, "${tablePrefix}", tablePrefix).trim();
+        sql = Text.replace(sql, "${tablePrefix}", tablePrefix + schemaObjectPrefix).trim();
         return sql;
     }
 
@@ -883,7 +889,7 @@
     }
 
     /**
-     * Get the table prefix. The default is empty.
+     * Get the table prefix. 
      *
      * @return the table prefix.
      */
@@ -892,12 +898,34 @@
     }
 
     /**
-     * Set the new table prefix.
+     * Set the new table prefix. The default is empty.
+     * The table name is constructed like this:
+     * ${tablePrefix}${schemaObjectPrefix}${tableName}
      *
      * @param tablePrefix the new value
      */
     public void setTablePrefix(String tablePrefix) {
         this.tablePrefix = tablePrefix;
     }
+    
+    /**
+     * Get the schema prefix.
+     * 
+     * @return the schema object prefix
+     */
+    public String getSchemaObjectPrefix() {
+        return schemaObjectPrefix;
+    }
+
+    /**
+     * Set the schema object prefix. The default is empty.
+     * The table name is constructed like this:
+     * ${tablePrefix}${schemaObjectPrefix}${tableName}
+     * 
+     * @param schemaObjectPrefix the new prefix
+     */
+    public void setSchemaObjectPrefix(String schemaObjectPrefix) {
+        this.schemaObjectPrefix = schemaObjectPrefix;
+    }    
 
 }