jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r886191 [1/3] - in /jackrabbit/trunk: ./ jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/da...
Date Wed, 02 Dec 2009 16:13:00 GMT
Author: jukka
Date: Wed Dec  2 16:12:57 2009
New Revision: 886191

URL: http://svn.apache.org/viewvc?rev=886191&view=rev
Log:
JCR-1456: Database connection pooling

Merge back all changes from the JCR-1456 sandbox branch.

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/DataSourceConfig.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/DataSourceConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleFsPersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleFsPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/CachingPersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/CachingPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/DerbyPersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/DerbyPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/H2PersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/H2PersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/MSSqlPersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/MSSqlPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/MySqlPersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/MySqlPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/Oracle9PersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/Oracle9PersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/OraclePersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/OraclePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/PostgreSQLPersistenceManager.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/PostgreSQLPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/BundleBinding.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/BundleBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/BundleCache.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/BundleCache.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/DbNameIndex.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/DbNameIndex.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/ErrorHandling.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/ErrorHandling.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/HashMapIndex.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/HashMapIndex.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/ItemStateBinding.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/ItemStateBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/LRUNodeIdCache.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/LRUNodeIdCache.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/NGKDbNameIndex.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/NGKDbNameIndex.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/NodePropBundle.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/NodePropBundle.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/PostgreSQLNameIndex.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/PostgreSQLNameIndex.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/TrackingInputStream.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/util/TrackingInputStream.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/CheckSchemaOperation.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/CheckSchemaOperation.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DataSourceWrapper.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DataSourceWrapper.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DatabaseAware.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DatabaseAware.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DbUtility.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DbUtility.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DerbyConnectionHelper.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DerbyConnectionHelper.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/Oracle10R1ConnectionHelper.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/Oracle10R1ConnectionHelper.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/StreamWrapper.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/StreamWrapper.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/db2.ddl
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/db2.ddl
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/derby.ddl
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/derby.ddl
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/h2.ddl
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/h2.ddl
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/ingres.ddl
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/ingres.ddl
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/mssql.ddl
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/mssql.ddl
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/mysql.ddl
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/mysql.ddl
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/oracle.ddl
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/oracle.ddl
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/postgresql.ddl
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/pool/postgresql.ddl
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/DataSourceConfigTest.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/DataSourceConfigTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/ConnectionFactoryTest.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/ConnectionFactoryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/TestAll.java
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/TestAll.java
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/repository.xml
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/repository.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/default/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/default/
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/default/workspace.xml
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/default/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v1/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v1/
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v1/workspace.xml
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v1/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v2/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v2/
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v2/workspace.xml
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v2/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v3/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v3/
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v3/workspace.xml
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/index-format-v3/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/indexing-test/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/indexing-test/
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/indexing-test/workspace.xml
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/indexing-test/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/security/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/security/
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/security/workspace.xml
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/security/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/wsp-init-test/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/wsp-init-test/
    jackrabbit/trunk/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/wsp-init-test/workspace.xml
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository-descriptor-overlay/workspaces/wsp-init-test/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/wsp-init-test/
      - copied from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository/workspaces/wsp-init-test/
    jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/wsp-init-test/workspace.xml
      - copied unchanged from r886178, jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/repository/workspaces/wsp-init-test/workspace.xml
Removed:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DatabaseHelper.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/Pool.java
    jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/workspace-init-test/
Modified:
    jackrabbit/trunk/   (props changed)
    jackrabbit/trunk/jackrabbit-core/pom.xml
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DerbyDataStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DbFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DerbyFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/JNDIDatabaseFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
    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/journal/MSSqlDatabaseJournal.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/OracleDatabaseJournal.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/SimpleDbPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/repository.xml
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/SecurityConfigTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/TestAll.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/db/DerbyFileSystemTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/WorkspaceInitTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/repository/repository.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/default/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/index-format-v1/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/index-format-v2/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/index-format-v3/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/indexing-test/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml
    jackrabbit/trunk/jackrabbit-jca/src/main/rar/repository.xml
    jackrabbit/trunk/jackrabbit-spi2jcr/src/test/resources/repository.xml

Propchange: jackrabbit/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  2 16:12:57 2009
@@ -1,3 +1,4 @@
 /jackrabbit/branches/1.5:794012,794100,794102
+/jackrabbit/sandbox/JCR-1456:774917-886178
 /jackrabbit/sandbox/JCR-2170:812417-816332
 /jackrabbit/sandbox/tripod-JCR-2209:795441-795863

Modified: jackrabbit/trunk/jackrabbit-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/pom.xml?rev=886191&r1=886190&r2=886191&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/pom.xml Wed Dec  2 16:12:57 2009
@@ -97,6 +97,8 @@
               <value>
                 org.apache.jackrabbit.core.xml.DocumentViewTest#testMultiValue
                 org.apache.jackrabbit.core.ConcurrentImportTest
+                org.apache.jackrabbit.core.data.GarbageCollectorTest#testGC
+                org.apache.jackrabbit.core.data.GarbageCollectorTest#testCloseSessionWhileRunningGc
                 org.apache.jackrabbit.core.integration.ConcurrentQueryTest#testConcurrentQueryWithDeletes
               </value>
             </property>
@@ -164,6 +166,11 @@
       <artifactId>commons-io</artifactId>
     </dependency>
     <dependency>
+      <groupId>commons-dbcp</groupId>
+      <artifactId>commons-dbcp</artifactId>
+      <version>1.2.2</version>
+    </dependency>
+    <dependency>
       <groupId>javax.jcr</groupId>
       <artifactId>jcr</artifactId>
     </dependency>
@@ -249,4 +256,233 @@
     </dependency>
   </dependencies>
 
+  <!--
+    These profiles can be used to run the (integration) tests against different DB backends.
+    For instance, if you want to run the integration tests against MySQL backend, do:
+    
+      mvn clean integration-test -Pmysql,use-descriptor-overlay
+    
+    Note: the ${config.db.name} database is dropped and re-created in the clean phase. 
+  -->
+  <profiles>
+    <profile>
+      <id>mysql</id>
+      <properties>
+        <config.db.name>jackrabbit</config.db.name>
+        <config.db.fsclass>org.apache.jackrabbit.core.fs.db.DbFileSystem</config.db.fsclass>
+        <config.db.dsclass>org.apache.jackrabbit.core.data.db.DbDataStore</config.db.dsclass>
+        <config.db.pmclass>org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager</config.db.pmclass>
+        <config.db.journalclass>org.apache.jackrabbit.core.journal.DatabaseJournal</config.db.journalclass>
+        <config.db.schema>mysql</config.db.schema>
+        <config.db.validation.query>select 1</config.db.validation.query>
+        <config.db.user>user</config.db.user>
+        <config.db.pwd>pwd</config.db.pwd>
+        <config.db.driver>com.mysql.jdbc.Driver</config.db.driver>
+        <config.db.url>jdbc:mysql://localhost:3306/${config.db.name}?autoReconnect=true</config.db.url>
+        <config.db.metaurl>jdbc:mysql://localhost:3306/mysql?autoReconnect=true</config.db.metaurl>
+        <config.db.dropcommand>drop database ${config.db.name}</config.db.dropcommand>
+        <config.db.createcommand>create database ${config.db.name}</config.db.createcommand>
+      </properties>
+    </profile>
+    <profile>
+      <id>mssql</id>
+      <properties>
+        <config.db.name>jackrabbit</config.db.name>
+        <config.db.fsclass>org.apache.jackrabbit.core.fs.db.MSSqlFileSystem</config.db.fsclass>
+        <config.db.dsclass>org.apache.jackrabbit.core.data.db.DbDataStore</config.db.dsclass>
+        <config.db.pmclass>org.apache.jackrabbit.core.persistence.pool.MSSqlPersistenceManager</config.db.pmclass>
+        <config.db.journalclass>org.apache.jackrabbit.core.journal.MSSqlDatabaseJournal</config.db.journalclass>
+        <config.db.schema>mssql</config.db.schema>
+        <config.db.validation.query>select 1</config.db.validation.query>
+        <config.db.user>user</config.db.user>
+        <config.db.pwd>pwd</config.db.pwd>
+        <config.db.driver>net.sourceforge.jtds.jdbc.Driver</config.db.driver>
+        <config.db.url>jdbc:jtds:sqlserver://localhost:2433/${config.db.name}</config.db.url>
+        <config.db.metaurl>jdbc:jtds:sqlserver://localhost:2433/master</config.db.metaurl>
+        <config.db.dropcommand>drop database ${config.db.name}</config.db.dropcommand>
+        <config.db.createcommand>create database ${config.db.name}</config.db.createcommand>
+      </properties>
+    </profile>
+    <profile>
+      <id>oracle</id>
+      <properties>
+        <config.db.name>unused</config.db.name>
+        <config.db.fsclass>org.apache.jackrabbit.core.fs.db.OracleFileSystem</config.db.fsclass>
+        <config.db.dsclass>org.apache.jackrabbit.core.data.db.DbDataStore</config.db.dsclass>
+        <config.db.pmclass>org.apache.jackrabbit.core.persistence.pool.OraclePersistenceManager</config.db.pmclass>
+        <config.db.journalclass>org.apache.jackrabbit.core.journal.OracleDatabaseJournal</config.db.journalclass>
+        <config.db.schema>oracle</config.db.schema>
+        <config.db.validation.query>select 'validationQuery' from dual</config.db.validation.query>
+        <config.db.user>user</config.db.user>
+        <config.db.pwd>password</config.db.pwd>
+        <config.db.driver>oracle.jdbc.driver.OracleDriver</config.db.driver>
+        <config.db.url>jdbc:oracle:thin:@localhost:1521:xe</config.db.url>
+        <config.db.metaurl>unused</config.db.metaurl>
+        <config.db.dropcommand>unused</config.db.dropcommand>
+        <config.db.createcommand>unused</config.db.createcommand>
+      </properties>
+    </profile>
+    <profile>
+      <id>h2</id>
+      <dependencies>
+        <dependency>
+          <groupId>com.h2database</groupId>
+          <artifactId>h2</artifactId>
+          <version>1.2.121</version>
+        </dependency>
+      </dependencies>
+      <properties>
+        <config.db.name>jackrabbit</config.db.name>
+        <config.db.fsclass>org.apache.jackrabbit.core.fs.db.DbFileSystem</config.db.fsclass>
+        <config.db.dsclass>org.apache.jackrabbit.core.data.db.DbDataStore</config.db.dsclass>
+        <config.db.pmclass>org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager</config.db.pmclass>
+        <config.db.journalclass>org.apache.jackrabbit.core.journal.DatabaseJournal</config.db.journalclass>
+        <config.db.schema>h2</config.db.schema>
+        <config.db.validation.query>call 1</config.db.validation.query>
+        <config.db.user>sa</config.db.user>
+        <config.db.pwd>sa</config.db.pwd>
+        <config.db.driver>org.h2.Driver</config.db.driver>
+        <!-- <config.db.url>jdbc:h2:~/jackrabbit2;MAX_LENGTH_INPLACE_LOB=10240;DB_CLOSE_ON_EXIT=FALSE;TRACE_LEVEL_FILE=2</config.db.url> -->
+        <config.db.url>jdbc:h2:~/jackrabbit2;MAX_LENGTH_INPLACE_LOB=10240;DB_CLOSE_ON_EXIT=FALSE</config.db.url>
+        <config.db.metaurl>unused</config.db.metaurl>
+        <config.db.dropcommand>drop all objects delete files</config.db.dropcommand>
+        <config.db.createcommand>unused</config.db.createcommand>
+      </properties>
+    </profile>
+    <profile>
+      <id>use-descriptor-overlay</id>
+      <build>
+      <plugins>
+        <!-- Drop/create the test database on clean -->        
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>sql-maven-plugin</artifactId>
+          <dependencies>
+            <dependency>
+              <groupId>mysql</groupId>
+              <artifactId>mysql-connector-java</artifactId>
+              <version>5.1.6</version>
+              <type>jar</type>
+              <scope>provided</scope>
+            </dependency>
+            <dependency>
+              <groupId>net.sourceforge.jtds</groupId>
+              <artifactId>jtds</artifactId>
+              <version>1.2.2</version>
+              <scope>provided</scope>
+            </dependency>
+          </dependencies>
+          <configuration>
+            <driver>${config.db.driver}</driver>
+            <url>${config.db.metaurl}</url>
+            <username>${config.db.user}</username>
+            <password>${config.db.pwd}</password>
+            <settingsKey>sensibleKey</settingsKey>
+          </configuration>
+          <executions>
+            <execution>
+              <id>drop-db</id>
+              <phase>clean</phase>
+              <goals>
+                <goal>execute</goal>
+              </goals>
+              <configuration>
+                <autocommit>true</autocommit>
+                <sqlCommand>${config.db.dropcommand}</sqlCommand>
+                <onError>continue</onError>
+              </configuration>
+            </execution>
+            <execution>
+              <id>create-db</id>
+              <phase>clean</phase>
+              <goals>
+                <goal>execute</goal>
+              </goals>
+              <configuration>
+                <autocommit>true</autocommit>
+                <sqlCommand>${config.db.createcommand}</sqlCommand>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+        <plugin>
+          <artifactId>maven-antrun-plugin</artifactId>
+          <executions>
+            <execution>
+              <id>overlay-repository-descriptors</id>
+              <phase>process-test-resources</phase>
+              <configuration>
+                <tasks>
+                  <copy todir="${project.build.directory}/repository" overwrite="true">
+                    <fileset dir="${basedir}/src/test/repository-descriptor-overlay" />
+                    <filterset>
+                      <filter token="repo.id" value="A" />
+                      <filter token="config.db.schema" value="${config.db.schema}" />
+                      <filter token="config.db.validation.query" value="${config.db.validation.query}" />
+                      <filter token="config.db.driver" value="${config.db.driver}" />
+                      <filter token="config.db.url" value="${config.db.url}" />
+                      <filter token="config.db.user" value="${config.db.user}" />
+                      <filter token="config.db.pwd" value="${config.db.pwd}" />
+                      <filter token="config.db.fsclass" value="${config.db.fsclass}" />
+                      <filter token="config.db.dsclass" value="${config.db.dsclass}" />
+                      <filter token="config.db.pmclass" value="${config.db.pmclass}" />
+                      <filter token="config.db.journalclass" value="${config.db.journalclass}" />
+                    </filterset>
+                  </copy>
+                  <copy todir="${project.build.directory}/repository-2" overwrite="true">
+                    <fileset dir="${basedir}/src/test/repository-descriptor-overlay" />
+                    <filterset>
+                      <filter token="repo.id" value="B" />
+                      <filter token="config.db.schema" value="${config.db.schema}" />
+                      <filter token="config.db.validation.query" value="${config.db.validation.query}" />
+                      <filter token="config.db.driver" value="${config.db.driver}" />
+                      <filter token="config.db.url" value="${config.db.url}" />
+                      <filter token="config.db.user" value="${config.db.user}" />
+                      <filter token="config.db.pwd" value="${config.db.pwd}" />
+                      <filter token="config.db.fsclass" value="${config.db.fsclass}" />
+                      <filter token="config.db.dsclass" value="${config.db.dsclass}" />
+                      <filter token="config.db.pmclass" value="${config.db.pmclass}" />
+                      <filter token="config.db.journalclass" value="${config.db.journalclass}" />
+                    </filterset>
+                  </copy>
+                </tasks>
+              </configuration>
+              <goals>
+                <goal>run</goal>
+              </goals>
+            </execution>
+          </executions>
+          <dependencies>
+            <dependency>
+              <groupId>ant</groupId>
+              <artifactId>ant-optional</artifactId>
+              <version>1.5.3-1</version>
+            </dependency>
+          </dependencies>
+        </plugin>
+      </plugins>
+      </build>
+      <dependencies>
+        <dependency>
+          <groupId>mysql</groupId>
+          <artifactId>mysql-connector-java</artifactId>
+          <version>5.1.6</version>
+          <type>jar</type>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>net.sourceforge.jtds</groupId>
+          <artifactId>jtds</artifactId>
+          <version>1.2.2</version>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>com.oracle</groupId>
+          <artifactId>ojdbc14</artifactId>
+          <version>10.2.0.3.0</version>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
 </project>

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=886191&r1=886190&r2=886191&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java Wed Dec  2 16:12:57 2009
@@ -282,7 +282,7 @@
         boolean succeeded = false;
         try {
             this.repConfig = repConfig;
-
+            
             // setup file systems
             repStore = repConfig.getFileSystem();
             String fsRootPath = "/meta";
@@ -1198,6 +1198,8 @@
             log.warn("Interrupted while waiting for background threads", e);
         }
 
+        repConfig.getConnectionFactory().close();
+
         // finally release repository lock
         if (repLock != null) {
             try {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java?rev=886191&r1=886190&r2=886191&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java Wed Dec  2 16:12:57 2009
@@ -27,6 +27,8 @@
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.jackrabbit.core.util.db.ConnectionFactory;
+import org.apache.jackrabbit.core.util.db.DatabaseAware;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -81,6 +83,11 @@
     private final Properties properties;
 
     /**
+     * The repositories {@link ConnectionFactory}.
+     */
+    private ConnectionFactory connectionFactory = null;
+
+    /**
      * Flag to validate the configured bean property names against
      * the configured bean class. By default this is <code>true</code>
      * to prevent incorrect property names. However, in some cases this
@@ -118,6 +125,7 @@
      */
     public BeanConfig(BeanConfig config) {
         this(config.getClassName(), config.getParameters());
+        setConnectionFactory(config.connectionFactory);
     }
 
     /**
@@ -131,6 +139,14 @@
     }
 
     /**
+     * @param connectionFactory the {@link ConnectionFactory} to inject (if possible) in the
+     *            {@link #newInstance()} method
+     */
+    public void setConnectionFactory(ConnectionFactory connectionFactory) {
+        this.connectionFactory = connectionFactory;
+    }
+
+    /**
      * Returns the class name of the configured bean.
      *
      * @return class name of the bean
@@ -185,6 +201,10 @@
                 }
             }
 
+            if (instance instanceof DatabaseAware) {
+                ((DatabaseAware) instance).setConnectionFactory(connectionFactory);
+            }
+
             return (T) instance;
         } catch (ClassNotFoundException e) {
             throw new ConfigurationException(

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java?rev=886191&r1=886190&r2=886191&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java Wed Dec  2 16:12:57 2009
@@ -29,6 +29,7 @@
 import org.apache.jackrabbit.core.query.QueryHandlerFactory;
 import org.apache.jackrabbit.core.util.RepositoryLockMechanism;
 import org.apache.jackrabbit.core.util.RepositoryLockMechanismFactory;
+import org.apache.jackrabbit.core.util.db.ConnectionFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Element;
@@ -257,7 +258,7 @@
         variables.setProperty(
                 RepositoryConfigurationParser.REPOSITORY_HOME_VARIABLE, home);
         RepositoryConfigurationParser parser =
-            new RepositoryConfigurationParser(variables);
+            new RepositoryConfigurationParser(variables, new ConnectionFactory());
 
         RepositoryConfig config = parser.parseRepositoryConfig(xml);
         config.init();
@@ -349,6 +350,16 @@
     private final RepositoryLockMechanismFactory rlf;
 
     /**
+     * The configuration for the used DataSources.
+     */
+    private final DataSourceConfig dsc;
+
+    /**
+     * The {@link ConnectionFactory}
+     */
+    private final ConnectionFactory cf;
+
+    /**
      * Creates a repository configuration object.
      *
      * @param home repository home directory
@@ -363,6 +374,9 @@
      * @param qhf query handler factory for the system search manager
      * @param cc optional cluster configuration
      * @param dsf data store factory
+     * @param rlf the RepositoryLockMechanismFactory
+     * @param dsc the DataSource configuration
+     * @param cf the ConnectionFactory for all DatabasAware beans
      * @param parser configuration parser
      */
     public RepositoryConfig(
@@ -372,6 +386,8 @@
             Element template, VersioningConfig vc, QueryHandlerFactory qhf,
             ClusterConfig cc, DataStoreFactory dsf,
             RepositoryLockMechanismFactory rlf,
+            DataSourceConfig dsc,
+            ConnectionFactory cf,
             RepositoryConfigurationParser parser) {
         workspaces = new HashMap<String, WorkspaceConfig>();
         this.home = home;
@@ -387,6 +403,8 @@
         this.cc = cc;
         this.dsf = dsf;
         this.rlf = rlf;
+        this.dsc = dsc;
+        this.cf = cf;
         this.parser = parser;
     }
 
@@ -399,6 +417,15 @@
      *                               been initialized
      */
     public void init() throws ConfigurationException, IllegalStateException {
+        
+        // This needs to be done here and not by clients (e.g., RepositoryImpl ctor) because
+        // fsf is used below and this might be a DatabaseAware FileSystem
+        try {
+            cf.registerDataSources(dsc);
+        } catch (RepositoryException e) {
+            throw new ConfigurationException("failed to register data sources", e);
+        }
+
         if (!workspaces.isEmpty()) {
             throw new IllegalStateException(
                     "Repository configuration has already been initialized.");
@@ -915,6 +942,14 @@
     }
 
     /**
+     * Returns the {@link ConnectionFactory} for this repository.
+     * Please note that it must be closed explicitly.
+     */
+    public ConnectionFactory getConnectionFactory() {
+        return cf;
+    }
+
+    /**
      * Creates and returns the configured data store. Returns
      * <code>null</code> if a data store has not been configured.
      *

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java?rev=886191&r1=886190&r2=886191&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java Wed Dec  2 16:12:57 2009
@@ -36,6 +36,7 @@
 import org.apache.jackrabbit.core.util.RepositoryLock;
 import org.apache.jackrabbit.core.util.RepositoryLockMechanism;
 import org.apache.jackrabbit.core.util.RepositoryLockMechanismFactory;
+import org.apache.jackrabbit.core.util.db.ConnectionFactory;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -118,6 +119,12 @@
     /** Name of the cluster configuration element. */
     public static final String CLUSTER_ELEMENT = "Cluster";
 
+    /** Name of the data source configuration element. */
+    public static final String DATASOURCES_ELEMENT = "DataSources";
+
+    /** Name of the data source configuration element. */
+    public static final String DATASOURCE_ELEMENT = "DataSource";
+
     /** Name of the journal configuration element. */
     public static final String JOURNAL_ELEMENT = "Journal";
 
@@ -183,6 +190,11 @@
     private static final String AC_PROVIDER_ELEMENT = "AccessControlProvider";
 
     /**
+     * The repositories {@link ConnectionFactory}. 
+     */
+    private final ConnectionFactory connectionFactory;
+
+    /**
      * Element specifying the class of principals used to retrieve the userID
      * in the 'class' attribute.
      */
@@ -205,8 +217,9 @@
      *
      * @param variables parser variables
      */
-    public RepositoryConfigurationParser(Properties variables) {
+    public RepositoryConfigurationParser(Properties variables, ConnectionFactory connectionFactory) {
         super(variables);
+        this.connectionFactory = connectionFactory;
     }
 
     /**
@@ -304,9 +317,33 @@
 
         RepositoryLockMechanismFactory rlf = getRepositoryLockMechanismFactory(root);
 
+        // Optional data source configuration
+        DataSourceConfig dsc = parseDataSourceConfig(root);
+
         return new RepositoryConfig(home, securityConfig, fsf,
                 workspaceDirectory, workspaceConfigDirectory, defaultWorkspace,
-                maxIdleTime, template, vc, qhf, cc, dsf, rlf, this);
+                maxIdleTime, template, vc, qhf, cc, dsf, rlf, dsc, connectionFactory, this);
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected BeanConfig parseBeanConfig(Element parent, String name) throws ConfigurationException {
+        BeanConfig cfg = super.parseBeanConfig(parent, name);
+        cfg.setConnectionFactory(connectionFactory);
+        return cfg;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected BeanConfig parseBeanConfig(Element element) throws ConfigurationException {
+        BeanConfig cfg = super.parseBeanConfig(element);
+        cfg.setConnectionFactory(connectionFactory);
+        return cfg;
     }
 
     /**
@@ -845,6 +882,38 @@
     }
 
     /**
+     * TODO
+     * 
+     * @param parent
+     * @return
+     * @throws ConfigurationException
+     */
+    protected DataSourceConfig parseDataSourceConfig(Element parent)
+            throws ConfigurationException {
+        DataSourceConfig dsc = new DataSourceConfig();
+        NodeList children = parent.getChildNodes();
+        for (int i = 0; i < children.getLength(); i++) {
+            Node child = children.item(i);
+            if (child.getNodeType() == Node.ELEMENT_NODE
+                    && DATASOURCES_ELEMENT.equals(child.getNodeName())) {
+                Element element = (Element) child;
+                NodeList children2 = element.getChildNodes();
+                // Process the DataSource entries:
+                for (int j = 0; j < children2.getLength(); j++) {
+                    Node child2 = children2.item(j);
+                    if (child2.getNodeType() == Node.ELEMENT_NODE
+                            && DATASOURCE_ELEMENT.equals(child2.getNodeName())) {
+                        Element dsdef = (Element) child2;
+                        Properties props = parseParameters(dsdef);
+                        dsc.addDataSourceDefinition(props);
+                    }
+                }
+            }
+        }
+        return dsc;
+    }
+
+    /**
      * Parses data store configuration. Data store configuration uses the following format:
      * <pre>
      *   &lt;DataStore class="..."&gt;
@@ -933,7 +1002,7 @@
 
     /**
      * Creates a new instance of a configuration parser but with overlayed
-     * variables.
+     * variables and the same connection factory as this parser.
      *
      * @param variables the variables overlay
      * @return a new configuration parser instance
@@ -942,7 +1011,7 @@
         // overlay the properties
         Properties props = new Properties(getVariables());
         props.putAll(variables);
-        return new RepositoryConfigurationParser(props);
+        return new RepositoryConfigurationParser(props, connectionFactory);
     }
 
     /**

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=886191&r1=886190&r2=886191&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  2 16:12:57 2009
@@ -20,9 +20,13 @@
 import org.apache.jackrabbit.core.data.DataRecord;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.data.DataStoreException;
-import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager;
-import org.apache.jackrabbit.core.persistence.bundle.util.TrackingInputStream;
-import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager.StreamWrapper;
+import org.apache.jackrabbit.core.persistence.pool.util.TrackingInputStream;
+import org.apache.jackrabbit.core.util.db.CheckSchemaOperation;
+import org.apache.jackrabbit.core.util.db.ConnectionFactory;
+import org.apache.jackrabbit.core.util.db.ConnectionHelper;
+import org.apache.jackrabbit.core.util.db.DatabaseAware;
+import org.apache.jackrabbit.core.util.db.DbUtility;
+import org.apache.jackrabbit.core.util.db.StreamWrapper;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,8 +40,6 @@
 import java.security.DigestInputStream;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
-import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -49,6 +51,7 @@
 import java.util.WeakHashMap;
 
 import javax.jcr.RepositoryException;
+import javax.sql.DataSource;
 
 /**
  * A data store implementation that stores the records in a database using JDBC.
@@ -93,7 +96,7 @@
  * The tablePrefix can be used to specify a schema and / or catalog name:
  * &lt;param name="tablePrefix" value="ds.">
  */
-public class DbDataStore implements DataStore {
+public class DbDataStore implements DataStore, DatabaseAware {
 
     /**
      * The default value for the minimum object size.
@@ -101,11 +104,6 @@
     public static final int DEFAULT_MIN_RECORD_LENGTH = 100;
 
     /**
-     * The default value for the maximum connections.
-     */
-    public static final int DEFAULT_MAX_CONNECTIONS = 3;
-    
-    /**
      * Write to a temporary file to get the length (slow, but always works).
      * This is the default setting.
      */
@@ -173,16 +171,6 @@
     protected int minRecordLength = DEFAULT_MIN_RECORD_LENGTH;
 
     /**
-     * The maximum number of open connections.
-     */
-    protected int maxConnections = DEFAULT_MAX_CONNECTIONS;
-
-    /**
-     * A list of connections
-     */
-    protected Pool connectionPool;
-
-    /**
      * The prefix for the datastore table, empty by default.
      */
     protected String tablePrefix = "";
@@ -198,6 +186,11 @@
     private boolean schemaCheckEnabled = true;
 
     /**
+     * The logical name of the DataSource to use.
+     */
+    protected String dataSourceName;
+
+    /**
      * This is the property 'table'
      * in the [databaseType].properties file, initialized with the default value.
      */
@@ -297,34 +290,49 @@
     protected List<String> temporaryInUse = Collections.synchronizedList(new ArrayList<String>());
 
     /**
+     * The {@link ConnectionHelper} set in the {@link #init(String)} method.
+     * */
+    protected ConnectionHelper conHelper;
+
+    /**
+     * The repositories {@link ConnectionFactory}.
+     */
+    private ConnectionFactory connectionFactory;
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setConnectionFactory(ConnectionFactory connnectionFactory) {
+        this.connectionFactory = connnectionFactory;
+    }
+
+    /**
      * {@inheritDoc}
      */
     public DataRecord addRecord(InputStream stream) throws DataStoreException {
         ResultSet rs = null;
         TempFileInputStream fileInput = null;
-        ConnectionRecoveryManager conn = getConnection();
         String id = null, tempId = null;
         try {
             long now;
-            for (int i = 0; i < ConnectionRecoveryManager.TRIALS; i++) {
+            while(true) {
                 try {
                     now = System.currentTimeMillis();
                     id = UUID.randomUUID().toString();
                     tempId = TEMP_PREFIX + id;
                     // SELECT LENGTH, LAST_MODIFIED FROM DATASTORE WHERE ID=?
-                    PreparedStatement prep = conn.executeStmt(selectMetaSQL, new Object[]{tempId});
-                    rs = prep.getResultSet();
+                    rs = conHelper.exec(selectMetaSQL, new Object[]{tempId}, false, 0);
                     if (rs.next()) {
                         // re-try in the very, very unlikely event that the row already exists
                         continue;
                     }
                     // INSERT INTO DATASTORE VALUES(?, 0, ?, NULL)
-                    conn.executeStmt(insertTempSQL, new Object[]{tempId, new Long(now)});
+                    conHelper.exec(insertTempSQL, new Object[]{tempId, new Long(now)});
                     break;
                 } catch (Exception e) {
                     throw convert("Can not insert new record", e);
                 } finally {
-                    DatabaseHelper.closeSilently(rs);
+                    DbUtility.close(rs);
                 }
             }
             if (id == null) {
@@ -350,7 +358,7 @@
                 throw new DataStoreException("Unsupported stream store algorithm: " + storeStream);
             }
             // UPDATE DATASTORE SET DATA=? WHERE ID=?
-            conn.executeStmt(updateDataSQL, new Object[]{wrapper, tempId});
+            conHelper.exec(updateDataSQL, new Object[]{wrapper, tempId});
             now = System.currentTimeMillis();
             long length = in.getPosition();
             DataIdentifier identifier = new DataIdentifier(digest.digest());
@@ -359,17 +367,16 @@
             // UPDATE DATASTORE SET ID=?, LENGTH=?, LAST_MODIFIED=?
             // WHERE ID=?
             // AND NOT EXISTS(SELECT ID FROM DATASTORE WHERE ID=?)
-            PreparedStatement prep = conn.executeStmt(updateSQL, new Object[]{
+            int count = conHelper.update(updateSQL, new Object[]{
                     id, new Long(length), new Long(now),
                     tempId, id});
-            int count = prep.getUpdateCount();
+            rs = null; // prevent that rs.close() is called in finally block if count != 0 (rs is closed above)
             if (count == 0) {
                 // update count is 0, meaning such a row already exists
                 // DELETE FROM DATASTORE WHERE ID=?
-                conn.executeStmt(deleteSQL, new Object[]{tempId});
+                conHelper.exec(deleteSQL, new Object[]{tempId});
                 // SELECT LENGTH, LAST_MODIFIED FROM DATASTORE WHERE ID=?
-                prep = conn.executeStmt(selectMetaSQL, new Object[]{id});
-                rs = prep.getResultSet();
+                rs = conHelper.exec(selectMetaSQL, new Object[]{id}, false, 0);
                 if (rs.next()) {
                     long oldLength = rs.getLong(1);
                     long lastModified = rs.getLong(2);
@@ -393,8 +400,7 @@
             if (tempId != null) {
                 temporaryInUse.remove(tempId);
             }
-            DatabaseHelper.closeSilently(rs);
-            putBack(conn);
+            DbUtility.close(rs);
             if (fileInput != null) {
                 try {
                     fileInput.close();
@@ -423,7 +429,6 @@
      * {@inheritDoc}
      */
     public synchronized int deleteAllOlderThan(long min) throws DataStoreException {
-        ConnectionRecoveryManager conn = getConnection();
         try {
             ArrayList<String> touch = new ArrayList<String>();
             ArrayList<DataIdentifier> ids = new ArrayList<DataIdentifier>(inUse.keySet());
@@ -437,12 +442,9 @@
                 updateLastModifiedDate(key, 0);
             }
             // DELETE FROM DATASTORE WHERE LAST_MODIFIED<?
-            PreparedStatement prep = conn.executeStmt(deleteOlderSQL, new Long[]{new Long(min)});
-            return prep.getUpdateCount();
+            return conHelper.update(deleteOlderSQL, new Long[]{new Long(min)});
         } catch (Exception e) {
             throw convert("Can not delete records", e);
-        } finally {
-            putBack(conn);
         }
     }
 
@@ -450,13 +452,11 @@
      * {@inheritDoc}
      */
     public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException {
-        ConnectionRecoveryManager conn = getConnection();
         ArrayList<DataIdentifier> list = new ArrayList<DataIdentifier>();
         ResultSet rs = null;
         try {
             // SELECT ID FROM DATASTORE
-            PreparedStatement prep = conn.executeStmt(selectAllSQL, new Object[0]);
-            rs = prep.getResultSet();
+            rs = conHelper.exec(selectAllSQL, new Object[0], false, 0);
             while (rs.next()) {
                 String id = rs.getString(1);
                 if (!id.startsWith(TEMP_PREFIX)) {
@@ -468,8 +468,7 @@
         } catch (Exception e) {
             throw convert("Can not read records", e);
         } finally {
-            DatabaseHelper.closeSilently(rs);
-            putBack(conn);
+            DbUtility.close(rs);
         }
     }
 
@@ -494,14 +493,12 @@
      * {@inheritDoc}
      */
     public DataRecord getRecordIfStored(DataIdentifier identifier) throws DataStoreException {
-        ConnectionRecoveryManager conn = getConnection();
         usesIdentifier(identifier);
         ResultSet rs = null;
         try {
             String id = identifier.toString();
             // SELECT LENGTH, LAST_MODIFIED FROM DATASTORE WHERE ID = ?
-            PreparedStatement prep = conn.executeStmt(selectMetaSQL, new Object[]{id});
-            rs = prep.getResultSet();
+            rs = conHelper.exec(selectMetaSQL, new Object[]{id}, false, 0);
             if (!rs.next()) {
                 throw new DataStoreException("Record not found: " + identifier);
             }
@@ -512,8 +509,7 @@
         } catch (Exception e) {
             throw convert("Can not read identifier " + identifier, e);
         } finally {
-            DatabaseHelper.closeSilently(rs);
-            putBack(conn);
+            DbUtility.close(rs);
         }
     }
     
@@ -538,36 +534,29 @@
      *          or if the given identifier is invalid
      */    
     InputStream openStream(DbInputStream inputStream, DataIdentifier identifier) throws DataStoreException {
-        ConnectionRecoveryManager conn = null;
         ResultSet rs = null;
         try {
-            conn = getConnection();
             // SELECT ID, DATA FROM DATASTORE WHERE ID = ?
-            PreparedStatement prep = conn.executeStmt(selectDataSQL, new Object[]{identifier.toString()});
-            rs = prep.getResultSet();
+            rs = conHelper.exec(selectDataSQL, new Object[]{identifier.toString()}, false, 0);
             if (!rs.next()) {
                 throw new DataStoreException("Record not found: " + identifier);
             }
             InputStream stream = rs.getBinaryStream(2);
             if (stream == null) {
                 stream = new ByteArrayInputStream(new byte[0]);
-                DatabaseHelper.closeSilently(rs);
-                putBack(conn);
+                DbUtility.close(rs);
             } else if (copyWhenReading) {
                 // If we copy while reading, create a temp file and close the stream
                 File temp = moveToTempFile(stream);
                 stream = new TempFileInputStream(temp);
-                DatabaseHelper.closeSilently(rs);
-                putBack(conn);
+                DbUtility.close(rs);
             } else {
                 stream = new BufferedInputStream(stream);
-                inputStream.setConnection(conn);
                 inputStream.setResultSet(rs);
             }
             return stream;
         } catch (Exception e) {
-            DatabaseHelper.closeSilently(rs);
-            putBack(conn);
+            DbUtility.close(rs);
             throw convert("Retrieving database resource ", e);
         }
     }
@@ -578,36 +567,67 @@
     public synchronized void init(String homeDir) throws DataStoreException {
         try {
             initDatabaseType();
-            connectionPool = new Pool(this, maxConnections);
-            ConnectionRecoveryManager conn = getConnection();
-            DatabaseMetaData meta = conn.getConnection().getMetaData();
-            log.info("Using JDBC driver " + meta.getDriverName() + " " + meta.getDriverVersion());
-            meta.getDriverVersion();
-            ResultSet rs = meta.getTables(null, null, schemaObjectPrefix + tableSQL, null);
-            boolean exists = rs.next();
-            rs.close();
-            if (!exists && isSchemaCheckEnabled()) {
-                // CREATE TABLE DATASTORE(ID VARCHAR(255) PRIMARY KEY, 
-                // LENGTH BIGINT, LAST_MODIFIED BIGINT, DATA BLOB)
-                conn.executeStmt(createTableSQL, null);
+
+            conHelper = createConnectionHelper(getDataSource());
+
+            if (isSchemaCheckEnabled()) {
+                createCheckSchemaOperation().run();
             }
-            putBack(conn);
         } catch (Exception e) {
             throw convert("Can not init data store, driver=" + driver + " url=" + url + " user=" + user + 
                     " schemaObjectPrefix=" + schemaObjectPrefix + " tableSQL=" + tableSQL + " createTableSQL=" + createTableSQL, e);
         }
     }
 
+    private DataSource getDataSource() throws Exception {
+        if (getDataSourceName() == null || "".equals(getDataSourceName())) {
+            return connectionFactory.getDataSource(getDriver(), getUrl(), getUser(), getPassword());
+        } else {
+            return connectionFactory.getDataSource(dataSourceName);
+        }
+    }
+
+    /**
+     * This method is called from the {@link #init(String)} method of this class and returns a
+     * {@link ConnectionHelper} instance which is assigned to the {@code conHelper} field. Subclasses may
+     * override it to return a specialized connection helper.
+     * 
+     * @param dataSrc the {@link DataSource} of this persistence manager
+     * @return a {@link ConnectionHelper}
+     * @throws Exception on error
+     */
+    protected ConnectionHelper createConnectionHelper(DataSource dataSrc) throws Exception {
+        return new ConnectionHelper(dataSrc, false);
+    }
+
+    /**
+     * This method is called from {@link #init(String)} after the
+     * {@link #createConnectionHelper(DataSource)} method, and returns a default {@link CheckSchemaOperation}.
+     * 
+     * @return a new {@link CheckSchemaOperation} instance
+     */
+    protected final CheckSchemaOperation createCheckSchemaOperation() {
+        String tableName = tablePrefix + schemaObjectPrefix + tableSQL;
+        return new CheckSchemaOperation(conHelper, new ByteArrayInputStream(createTableSQL.getBytes()), tableName);
+    }
+
     protected void initDatabaseType() throws DataStoreException {
-        boolean failIfNotFound;
+        boolean failIfNotFound = false;
         if (databaseType == null) {
-            if (!url.startsWith("jdbc:")) {
-                return;
+            if (dataSourceName != null) {
+                try {
+                    databaseType = connectionFactory.getDataBaseType(dataSourceName);
+                } catch (RepositoryException e) {
+                    throw new DataStoreException(e);
+                }
+            } else {
+                if (!url.startsWith("jdbc:")) {
+                    return;
+                }
+                int start = "jdbc:".length();
+                int end = url.indexOf(':', start);
+                databaseType = url.substring(start, end);
             }
-            failIfNotFound = false;
-            int start = "jdbc:".length();
-            int end = url.indexOf(':', start);
-            databaseType = url.substring(start, end);
         } else {
             failIfNotFound = true;
         }
@@ -722,17 +742,14 @@
         if (lastModified < minModifiedDate) {
             long now = System.currentTimeMillis();
             Long n = new Long(now);
-            ConnectionRecoveryManager conn = getConnection();
             try {
                 // UPDATE DATASTORE SET LAST_MODIFIED = ? WHERE ID = ? AND LAST_MODIFIED < ?
-                conn.executeStmt(updateLastModifiedSQL, new Object[]{
+                conHelper.exec(updateLastModifiedSQL, new Object[]{
                         n, key, n
                 });
                 return now;
             } catch (Exception e) {
                 throw convert("Can not update lastModified", e);
-            } finally {
-                putBack(conn);
             }
         }
         return lastModified;
@@ -849,11 +866,6 @@
      * {@inheritDoc}
      */
     public synchronized void close() throws DataStoreException {
-        ArrayList<ConnectionRecoveryManager> list = connectionPool.getAll();
-        for (ConnectionRecoveryManager conn : list) {
-            conn.close();
-        }
-        list.clear();
     }
 
     protected void usesIdentifier(DataIdentifier identifier) {
@@ -875,53 +887,24 @@
         }
     }
 
-    protected ConnectionRecoveryManager getConnection() throws DataStoreException {
-        try {
-            ConnectionRecoveryManager conn = (ConnectionRecoveryManager) connectionPool.get();
-            conn.setAutoReconnect(true);
-            return conn;
-        } catch (InterruptedException e) {
-            throw new DataStoreException("Interrupted", e);
-        } catch (RepositoryException e) {
-            throw new DataStoreException("Can not open a new connection", e);
-        }
-    }
-
-    protected void putBack(ConnectionRecoveryManager conn) throws DataStoreException {
-        try {
-            connectionPool.add(conn);
-        } catch (InterruptedException e) {
-            throw new DataStoreException("Interrupted", e);
-        }
-    }
-
     /**
      * Get the maximum number of concurrent connections.
      *
+     * @deprecated
      * @return the maximum number of connections.
      */
     public int getMaxConnections() {
-        return maxConnections;
+        return -1;
     }
 
     /**
      * Set the maximum number of concurrent connections in the pool.
      * At least 3 connections are required if the garbage collection process is used.
      *
+     *@deprecated
      * @param maxConnections the new value
      */
     public void setMaxConnections(int maxConnections) {
-        this.maxConnections = maxConnections;
-    }
-
-    /**
-     * Create a new connection.
-     *
-     * @return the new connection
-     */
-    public ConnectionRecoveryManager createNewConnection() throws RepositoryException {
-        ConnectionRecoveryManager conn = new ConnectionRecoveryManager(false, driver, url, user, password);
-        return conn;
     }
 
     /**
@@ -983,4 +966,11 @@
         this.schemaObjectPrefix = schemaObjectPrefix;
     }    
 
+    public String getDataSourceName() {
+        return dataSourceName;
+    }
+
+    public void setDataSourceName(String dataSourceName) {
+        this.dataSourceName = dataSourceName;
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java?rev=886191&r1=886190&r2=886191&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java Wed Dec  2 16:12:57 2009
@@ -23,7 +23,7 @@
 import org.apache.commons.io.input.AutoCloseInputStream;
 import org.apache.jackrabbit.core.data.DataIdentifier;
 import org.apache.jackrabbit.core.data.DataStoreException;
-import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager;
+import org.apache.jackrabbit.core.util.db.DbUtility;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,8 +39,7 @@
     protected DbDataStore store;
     protected DataIdentifier identifier;
     protected boolean endOfStream;
-    
-    protected ConnectionRecoveryManager conn;
+
     protected ResultSet rs;
     
 
@@ -130,16 +129,9 @@
             // some additional database objects 
             // may need to be closed
             if (rs != null) {
-                DatabaseHelper.closeSilently(rs);
+                DbUtility.close(rs);
                 rs = null;
             }
-            if (conn != null) {
-                try {
-                    store.putBack(conn);
-                } catch (DataStoreException e) {
-                    log.info("Error closing DbResource", e);
-                }
-            }
         }
     }
 
@@ -208,16 +200,6 @@
     }
 
     /**
-     * Set the database connection of this input stream. This object must be
-     * closed once the stream is closed.
-     * 
-     * @param conn the connection
-     */
-    void setConnection(ConnectionRecoveryManager conn) {
-        this.conn = conn;
-    }
-
-    /**
      * Set the result set of this input stream. This object must be closed once
      * the stream is closed.
      * 
@@ -226,5 +208,4 @@
     void setResultSet(ResultSet rs) {
         this.rs = rs;
     }
-
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DerbyDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DerbyDataStore.java?rev=886191&r1=886190&r2=886191&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DerbyDataStore.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DerbyDataStore.java Wed Dec  2 16:12:57 2009
@@ -16,14 +16,13 @@
  */
 package org.apache.jackrabbit.core.data.db;
 
-import java.sql.DriverManager;
 import java.sql.SQLException;
 
+import javax.sql.DataSource;
+
 import org.apache.jackrabbit.core.data.DataStoreException;
-import org.apache.jackrabbit.core.persistence.bundle.DerbyPersistenceManager;
-import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.core.util.db.ConnectionHelper;
+import org.apache.jackrabbit.core.util.db.DerbyConnectionHelper;
 
 /**
  * The Derby data store closes the database when the data store is closed
@@ -32,49 +31,22 @@
 public class DerbyDataStore extends DbDataStore {
 
     /**
-     * Logger instance
+     * {@inheritDoc}
      */
-    private static Logger log = LoggerFactory.getLogger(DerbyDataStore.class);
+    @Override
+    protected ConnectionHelper createConnectionHelper(DataSource dataSrc) throws Exception {
+        return new DerbyConnectionHelper(dataSrc, false);
+    }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public synchronized void close() throws DataStoreException {
         super.close();
-
-        // check for embedded driver
-        if (!DerbyPersistenceManager.DERBY_EMBEDDED_DRIVER.equals(getDriver())) {
-            return;
-        }
-
         try {
-
-            // prepare connection url for issuing shutdown command
-            ConnectionRecoveryManager connectionManager = getConnection();
-
-            String url = connectionManager.getConnection().getMetaData().getURL();
-            int pos = url.lastIndexOf(';');
-            if (pos != -1) {
-                // strip any attributes from connection url
-                url = url.substring(0, pos);
-            }
-            url += ";shutdown=true";
-
-            // we have to reset the connection to 'autoCommit=true' before closing it;
-            // otherwise Derby would mysteriously complain about some pending uncommitted
-            // changes which can't possibly be true.
-            // @todo further investigate
-            connectionManager.getConnection().setAutoCommit(true);
-
-            // need to call it again because we just opened a connection,
-            // and super.close() closes it.
-            super.close();
-
-            // now it's safe to shutdown the embedded Derby database
-            try {
-                DriverManager.getConnection(url);
-            } catch (SQLException e) {
-                // a shutdown command always raises a SQLException
-                log.info(e.getMessage());
-            }
-        } catch (Exception e) {
+            ((DerbyConnectionHelper) conHelper).shutDown(getDriver());
+        } catch (SQLException e) {
             throw new DataStoreException(e);
         }
     }



Mime
View raw message