You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2006/03/19 13:19:06 UTC
svn commit: r386957 - in
/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core:
fs/db/DatabaseFileSystem.java state/db/DatabasePersistenceManager.java
Author: jukka
Date: Sun Mar 19 04:19:04 2006
New Revision: 386957
URL: http://svn.apache.org/viewcvs?rev=386957&view=rev
Log:
JCR-313: Restored the initConnection() method to allow external subclasses to override either initConnection() or getConnection().
Modified:
incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/db/DatabasePersistenceManager.java
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java?rev=386957&r1=386956&r2=386957&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java Sun Mar 19 04:19:04 2006
@@ -46,14 +46,16 @@
import java.util.ArrayList;
/**
- * Abstract base class for database file systems. This class contains common
+ * Base class for database file systems. This class contains common
* functionality for database file system subclasses that normally differ only
- * in the way the database connection is acquired.
+ * in the way the database connection is acquired. Subclasses should override
+ * the {@link #getConnection()} method to return the configured database
+ * connection.
* <p>
* See the {@link DbFileSystem} for a detailed description of the available
* configuration options and database behaviour.
*/
-public abstract class DatabaseFileSystem implements FileSystem {
+public class DatabaseFileSystem implements FileSystem {
/**
* Logger instance
@@ -161,8 +163,7 @@
try {
// setup jdbc connection
- con = getConnection();
- con.setAutoCommit(false);
+ initConnection();
// make sure schemaObjectPrefix consists of legal name characters only
prepareSchemaObjectPrefix();
@@ -1068,11 +1069,26 @@
//----------------------------------< misc. helper methods & overridables >
/**
+ * Initializes the database connection used by this file system.
+ * <p>
+ * Subclasses should normally override the {@link #getConnection()}
+ * method instead of this one. The default implementation calls
+ * {@link #getConnection()} to get the database connection and disables
+ * the autocommit feature.
+ *
+ * @throws Exception if an error occurs
+ */
+ protected void initConnection() throws Exception {
+ con = getConnection();
+ con.setAutoCommit(false);
+ }
+
+ /**
* Abstract factory method for creating a new database connection. This
- * method is called by {@link #init()} when the file system is started.
- * The returned connection should come with the default JDBC settings,
- * as the {@link #init()} method will explicitly set the
- * <code>autoCommit</code> and other properties as needed.
+ * method is called by {@link #initConnection()} when the file system is
+ * started. The returned connection should come with the default JDBC
+ * settings, as the {@link #initConnection()} method will explicitly set
+ * the <code>autoCommit</code> and other properties as needed.
* <p>
* Note that the returned database connection is kept during the entire
* lifetime of the file system, after which it is closed by
@@ -1081,7 +1097,9 @@
* @return new connection
* @throws Exception if an error occurs
*/
- protected abstract Connection getConnection() throws Exception;
+ protected Connection getConnection() throws Exception {
+ throw new UnsupportedOperationException("Override in a subclass!");
+ }
/**
* Closes the given database connection. This method is called by
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/db/DatabasePersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/db/DatabasePersistenceManager.java?rev=386957&r1=386956&r2=386957&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/db/DatabasePersistenceManager.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/db/DatabasePersistenceManager.java Sun Mar 19 04:19:04 2006
@@ -60,6 +60,8 @@
* Abstract base class for database persistence managers. This class
* contains common functionality for database persistence manager subclasses
* that normally differ only in the way the database connection is acquired.
+ * Subclasses should override the {@link #getConnection()} method to return
+ * the configured database connection.
* <p>
* See the {@link SimpleDbPersistenceManager} for a detailed description
* of the available configuration options and database behaviour.
@@ -178,8 +180,7 @@
}
// setup jdbc connection
- con = getConnection();
- con.setAutoCommit(false);
+ initConnection();
// make sure schemaObjectPrefix consists of legal name characters only
prepareSchemaObjectPrefix();
@@ -787,6 +788,21 @@
//----------------------------------< misc. helper methods & overridables >
/**
+ * Initializes the database connection used by this file system.
+ * <p>
+ * Subclasses should normally override the {@link #getConnection()}
+ * method instead of this one. The default implementation calls
+ * {@link #getConnection()} to get the database connection and disables
+ * the autocommit feature.
+ *
+ * @throws Exception if an error occurs
+ */
+ protected void initConnection() throws Exception {
+ con = getConnection();
+ con.setAutoCommit(false);
+ }
+
+ /**
* Abstract factory method for creating a new database connection. This
* method is called by {@link #init(PMContext)} when the persistence
* manager is started. The returned connection should come with the default
@@ -800,7 +816,9 @@
* @return new connection
* @throws Exception if an error occurs
*/
- protected abstract Connection getConnection() throws Exception;
+ protected Connection getConnection() throws Exception {
+ throw new UnsupportedOperationException("Override in a subclass!");
+ }
/**
* Closes the given database connection. This method is called by