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/02 15:16:12 UTC

svn commit: r722463 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: journal/DatabaseJournal.java persistence/bundle/BundleDbPersistenceManager.java

Author: thomasm
Date: Tue Dec  2 06:16:12 2008
New Revision: 722463

URL: http://svn.apache.org/viewvc?rev=722463&view=rev
Log:
JCR-1836: Persistence: support property databaseType

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java?rev=722463&r1=722462&r2=722463&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java Tue Dec  2 06:16:12 2008
@@ -49,8 +49,8 @@
  * property with no default value</li>
  * <li><code>url</code>: the JDBC connection url; this is a required property with
  * no default value </li>
- * <li><code>schema</code>: the schema to be used; if not specified, this is the
- * second field inside the JDBC connection url, delimeted by colons</li>
+ * <li><code>databaseType</code>: the database type to be used; if not specified, this is the
+ * second field inside the JDBC connection url, delimited by colons</li>
  * <li><code>schemaObjectPrefix</code>: the schema object prefix to be used;
  * defaults to an empty string</li>
  * <li><code>user</code>: username to specify when connecting</li>
@@ -118,9 +118,9 @@
     private String url;
 
     /**
-     * Schema name, bean property.
+     * Database type, bean property.
      */
-    private String schema;
+    private String databaseType;
 
     /**
      * User name, bean property.
@@ -317,7 +317,7 @@
      * Completes initialization of this database journal. Base implementation
      * checks whether the required bean properties <code>driver</code> and
      * <code>url</code> have been specified and optionally deduces a valid
-     * schema. Should be overridden by subclasses that use a different way to
+     * database type. Should be overridden by subclasses that use a different way to
      * create a connection and therefore require other arguments.
      *
      * @see #getConnection()
@@ -333,11 +333,11 @@
             throw new JournalException(msg);
         }
 
-        if (schema == null) {
+        if (databaseType == null) {
             try {
-                schema = getSchemaFromURL(url);
+                databaseType = getDatabaseTypeFromURL(url);
             } catch (IllegalArgumentException e) {
-                String msg = "Unable to derive schema from URL: " + e.getMessage();
+                String msg = "Unable to derive database type from URL: " + e.getMessage();
                 throw new JournalException(msg);
             }
         }
@@ -414,14 +414,14 @@
     }
 
     /**
-     * Derive a schema from a JDBC connection URL. This simply treats the given URL
+     * Derive a database type from a JDBC connection URL. This simply treats the given URL
      * as delimeted by colons and takes the 2nd field.
      *
      * @param url JDBC connection URL
-     * @return schema
+     * @return the database type
      * @throws IllegalArgumentException if the JDBC connection URL is invalid
      */
-    private static String getSchemaFromURL(String url) throws IllegalArgumentException {
+    private static String getDatabaseTypeFromURL(String url) throws IllegalArgumentException {
         int start = url.indexOf(':');
         if (start != -1) {
             int end = url.indexOf(':', start + 1);
@@ -774,9 +774,9 @@
      */
     private void checkSchema() throws Exception {
         if (!tableExists(connection.getMetaData(), schemaObjectPrefix + DEFAULT_JOURNAL_TABLE)) {            // read ddl from resources
-            InputStream in = DatabaseJournal.class.getResourceAsStream(schema + ".ddl");
+            InputStream in = DatabaseJournal.class.getResourceAsStream(databaseType + ".ddl");
             if (in == null) {
-                String msg = "No schema-specific DDL found: '" + schema + ".ddl"
+                String msg = "No database-specific DDL found: '" + databaseType + ".ddl"
                     + "', falling back to '" + DEFAULT_DDL_NAME + "'.";
                 log.info(msg);
                 in = DatabaseJournal.class.getResourceAsStream(DEFAULT_DDL_NAME);
@@ -817,9 +817,9 @@
         if (!tableExists(connection.getMetaData(), schemaObjectPrefix + LOCAL_REVISIONS_TABLE)) {
             log.info("Creating " + schemaObjectPrefix + LOCAL_REVISIONS_TABLE + " table");
             // read ddl from resources
-            InputStream in = DatabaseJournal.class.getResourceAsStream(schema + ".ddl");
+            InputStream in = DatabaseJournal.class.getResourceAsStream(databaseType + ".ddl");
             if (in == null) {
-                String msg = "No schema-specific DDL found: '" + schema + ".ddl" +
+                String msg = "No database-specific DDL found: '" + databaseType + ".ddl" +
                         "', falling back to '" + DEFAULT_DDL_NAME + "'.";
                 log.info(msg);
                 in = DatabaseJournal.class.getResourceAsStream(DEFAULT_DDL_NAME);
@@ -949,8 +949,24 @@
         return url;
     }
 
+    /**
+     * Get the database type.
+     * 
+     * @return the database type
+     */
+    public String getDatabaseType() {
+        return databaseType;
+    }
+
+    /**
+     * Get the database type.
+     * @deprecated
+     * This method is deprecated; {@link getDatabaseType} should be used instead.
+     * 
+     * @return the database type
+     */
     public String getSchema() {
-        return schema;
+        return databaseType;
     }
 
     public String getSchemaObjectPrefix() {
@@ -992,8 +1008,24 @@
         this.url = url;
     }
 
-    public void setSchema(String schema) {
-        this.schema = schema;
+    /**
+     * Set the database type.
+     * 
+     * @param databaseType the database type
+     */
+    public void setDatabaseType(String databaseType) {
+        this.databaseType = databaseType;
+    }
+
+    /**
+     * Set the database type.
+    * @deprecated
+    * This method is deprecated; {@link getDatabaseType} should be used instead.
+     * 
+     * @param databaseType the database type
+     */
+    public void setSchema(String databaseType) {
+        this.databaseType = databaseType;
     }
 
     public void setSchemaObjectPrefix(String schemaObjectPrefix) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java?rev=722463&r1=722462&r2=722463&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java Tue Dec  2 06:16:12 2008
@@ -82,7 +82,7 @@
  * <li>&lt;param name="{@link #setUrl(String) url}" value=""/>
  * <li>&lt;param name="{@link #setUser(String) user}" value=""/>
  * <li>&lt;param name="{@link #setPassword(String) password}" value=""/>
- * <li>&lt;param name="{@link #setSchema(String) schema}" value=""/>
+ * <li>&lt;param name="{@link #setDatabaseType(String) databaseType}" value=""/>
  * <li>&lt;param name="{@link #setSchemaObjectPrefix(String) schemaObjectPrefix}" value=""/>
  * <li>&lt;param name="{@link #setErrorHandling(String) errorHandling}" value=""/>
  * <li>&lt;param name="{@link #setBlockOnConnectionLoss(String) blockOnConnectionLoss}" value="false"/>
@@ -118,8 +118,8 @@
     /** the jdbc password */
     protected String password;
 
-    /** the schema identifier */
-    protected String schema;
+    /** the database type */
+    protected String databaseType;
 
     /** the prefix for the database objects */
     protected String schemaObjectPrefix;
@@ -279,22 +279,46 @@
     }
 
     /**
-     * Returns the configured schema identifier.
-     * @return the schema identifier.
+     * Returns the configured database type name.
+     * @deprecated
+     * This method is deprecated; {@link getDatabaseType} should be used instead.
+     * 
+     * @return the database type name.
      */
     public String getSchema() {
-        return schema;
+        return databaseType;
     }
 
     /**
-     * Sets the schema identifier. This identifier is used to load and execute
+     * Returns the configured database type name.
+     * @return the database type name.
+     */
+    public String getDatabaseType() {
+        return databaseType;
+    }
+
+    /**
+     * Sets the database type. This identifier is used to load and execute
+     * the respective .ddl resource in order to create the required schema
+     * objects.
+     * @deprecated
+     * This method is deprecated; {@link setDatabaseType} should be used instead.
+     *
+     * @param database type name
+     */
+    public void setSchema(String databaseType) {
+        this.databaseType = databaseType;
+    }
+    
+    /**
+     * Sets the database type. This identifier is used to load and execute
      * the respective .ddl resource in order to create the required schema
      * objects.
      *
-     * @param schema the schema identifier.
+     * @param database type name
      */
-    public void setSchema(String schema) {
-        this.schema = schema;
+    public void setDatabaseType(String databaseType) {
+        this.databaseType = databaseType;
     }
 
     /**
@@ -418,9 +442,9 @@
     protected void checkSchema() throws SQLException, RepositoryException {
         if (!checkTablesExist()) {
             // read ddl from resources
-            InputStream in = BundleDbPersistenceManager.class.getResourceAsStream(schema + ".ddl");
+            InputStream in = BundleDbPersistenceManager.class.getResourceAsStream(databaseType + ".ddl");
             if (in == null) {
-                String msg = "Configuration error: The resource '" + schema + ".ddl' could not be found";
+                String msg = "Configuration error: The resource '" + databaseType + ".ddl' could not be found";
                 log.debug(msg);
                 throw new RepositoryException(msg);
             }
@@ -441,7 +465,7 @@
                     sql = reader.readLine();
                 }
             } catch (IOException e) {
-                String msg = "Configuration error: unable to read the resource '" + schema + ".ddl': " + e;
+                String msg = "Configuration error: unable to read the resource '" + databaseType + ".ddl': " + e;
                 log.debug(msg);
                 throw new RepositoryException(msg, e);
             } catch (SQLException e) {