jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marti...@apache.org
Subject svn commit: r815298 - in /jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: config/ util/db/
Date Tue, 15 Sep 2009 12:35:49 GMT
Author: martijnh
Date: Tue Sep 15 12:35:48 2009
New Revision: 815298

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

Javadoc.


Modified:
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/DataSourceConfig.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DataSourceWrapper.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DbUtility.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DerbyConnectionHelper.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/Oracle10R1ConnectionHelper.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/DataSourceConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/DataSourceConfig.java?rev=815298&r1=815297&r2=815298&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/DataSourceConfig.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/DataSourceConfig.java
Tue Sep 15 12:35:48 2009
@@ -25,7 +25,7 @@
 import javax.naming.Context;
 
 /**
- * 
+ * This class contains list of definitions for {@code DataSource} instances.
  */
 public class DataSourceConfig {
 
@@ -64,6 +64,9 @@
         defs.add(def);
     }
 
+    /**
+     * @return the unmodifiable list of the current {@link DataSourceDefinition}s
+     */
     public List<DataSourceDefinition> getDefinitions() {
         return Collections.unmodifiableList(defs);
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java?rev=815298&r1=815297&r2=815298&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
Tue Sep 15 12:35:48 2009
@@ -68,7 +68,7 @@
     /**
      * Registers a number of data sources.
      * 
-     * @param dsc
+     * @param dsc the {@link DataSourceConfig} which contains the configuration
      */
     public static void registerDataSources(DataSourceConfig dsc) throws RepositoryException
{
         for (DataSourceDefinition def : dsc.getDefinitions()) {
@@ -98,9 +98,9 @@
     /**
      * Retrieves a configured data source by logical name.
      * 
-     * @param logicalName
-     * @return
-     * @throws RepositoryException
+     * @param logicalName the name of the {@code DataSource}
+     * @return a {@code DataSource}
+     * @throws RepositoryException if there is no {@code DataSource} with the given name
      */
     public static DataSource getDataSource(String logicalName) throws RepositoryException
{
         synchronized (lock) {
@@ -113,6 +113,11 @@
         }
     }
 
+    /**
+     * @param logicalName the name of the {@code DataSource}
+     * @return the configured database type
+     * @throws RepositoryException if there is no {@code DataSource} with the given name
+     */
     public static String getDataBaseType(String logicalName) throws RepositoryException {
         synchronized (lock) {
             DataSourceDefinition def = nameToDataSourceDef.get(logicalName);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java?rev=815298&r1=815297&r2=815298&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Tue Sep 15 12:35:48 2009
@@ -190,7 +190,6 @@
         if (!inBatchMode) {
             throw new IllegalStateException("not in batch mode");
         }
-        // Invariant: inBatchMode == true && batchConnection != null
         try {
             if (commit) {
                 batchConnection.commit();
@@ -399,7 +398,7 @@
     /**
      * This method is used by all methods of this class that execute SQL statements. This
default
      * implementation sets all parameters and unwraps {@link StreamWrapper} instances. Subclasses
may override
-     * this method to do something special with the parameters. E.g., the {@code Oracle10R1ConnectionHelper}
+     * this method to do something special with the parameters. E.g., the {@link Oracle10R1ConnectionHelper}
      * overrides it in order to add special blob handling.
      * 
      * @param stmt the {@link PreparedStatement} to execute

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DataSourceWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DataSourceWrapper.java?rev=815298&r1=815297&r2=815298&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DataSourceWrapper.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DataSourceWrapper.java
Tue Sep 15 12:35:48 2009
@@ -22,6 +22,11 @@
 
 import javax.sql.DataSource;
 
+/**
+ * This class delegates all calls to the corresponding method on the wrapped {@code DataSource}
except for the {@link #getConnection()} method,
+ * which delegates to {@code DataSource#getConnection(String, String)} with the username
and password
+ * which are given on construction.
+ */
 public class DataSourceWrapper implements DataSource {
 
     private final DataSource dataSource;
@@ -30,42 +35,74 @@
 
     private final String password;
 
+    /**
+     * @param dataSource the {@code DataSource} to wrap
+     * @param username the username to use
+     * @param password the password to use
+     */
     public DataSourceWrapper(DataSource dataSource, String username, String password) {
         this.dataSource = dataSource;
         this.username = username;
         this.password = password;
     }
 
+    /**
+     * Java 6 method.
+     * 
+     * {@inheritDoc}
+     */
     public boolean isWrapperFor(Class<?> arg0) throws SQLException {
         throw new UnsupportedOperationException("Java 6 method not supported");
     }
 
+    /**
+     * Java 6 method.
+     * 
+     * {@inheritDoc}
+     */
     public <T> T unwrap(Class<T> arg0) throws SQLException {
         throw new UnsupportedOperationException("Java 6 method not supported");
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public Connection getConnection() throws SQLException {
         return dataSource.getConnection(username, password);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public Connection getConnection(String username, String password) throws SQLException
{
         return dataSource.getConnection(username, password);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public PrintWriter getLogWriter() throws SQLException {
         return dataSource.getLogWriter();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public int getLoginTimeout() throws SQLException {
         return dataSource.getLoginTimeout();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public void setLogWriter(PrintWriter out) throws SQLException {
         dataSource.setLogWriter(out);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public void setLoginTimeout(int seconds) throws SQLException {
         dataSource.setLoginTimeout(seconds);
     }
-
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DbUtility.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DbUtility.java?rev=815298&r1=815297&r2=815298&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DbUtility.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DbUtility.java
Tue Sep 15 12:35:48 2009
@@ -25,7 +25,7 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * 
+ * This class contains some database utility methods.
  */
 public final class DbUtility {
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DerbyConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DerbyConnectionHelper.java?rev=815298&r1=815297&r2=815298&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DerbyConnectionHelper.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/DerbyConnectionHelper.java
Tue Sep 15 12:35:48 2009
@@ -36,8 +36,8 @@
     private static Logger log = LoggerFactory.getLogger(DerbyConnectionHelper.class);
 
     /**
-     * @param dataSrc the {@link DataSource} on which this helper acts
-     * @param block
+     * @param dataSrc the {@code DataSource} on which this helper acts
+     * @param block whether to block on connection loss until the db is up again
      */
     public DerbyConnectionHelper(DataSource dataSrc, boolean block) {
         super(dataSrc, block);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/Oracle10R1ConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/Oracle10R1ConnectionHelper.java?rev=815298&r1=815297&r2=815298&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/Oracle10R1ConnectionHelper.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/Oracle10R1ConnectionHelper.java
Tue Sep 15 12:35:48 2009
@@ -50,8 +50,8 @@
     private Integer modeReadWriteConstant;
 
     /**
-     * @param dataSrc
-     * @param block
+     * @param dataSrc the {@code DataSource} on which this helper acts
+     * @param block whether to block on connection loss until the db is up again
      */
     public Oracle10R1ConnectionHelper(DataSource dataSrc, boolean block) {
         super(dataSrc, block);
@@ -64,6 +64,7 @@
      * @see oracle.sql.BLOB#DURATION_SESSION
      * @see oracle.sql.BLOB#MODE_READWRITE
      */
+    @Override
     public void init() throws Exception {
         super.init();
         // initialize oracle.sql.BLOB class & constants

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java?rev=815298&r1=815297&r2=815298&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java
Tue Sep 15 12:35:48 2009
@@ -36,13 +36,19 @@
     private static Logger log = LoggerFactory.getLogger(OracleConnectionHelper.class);
 
     /**
-     * @param dataSrc
-     * @param block
+     * @param dataSrc the {@code DataSource} on which this helper acts
+     * @param block whether to block on connection loss until the db is up again
      */
     public OracleConnectionHelper(DataSource dataSrc, boolean block) {
         super(dataSrc, true, block);
     }
 
+    /**
+     * Initializes the helper: checks for valid driver version.
+     * Subclasses that override this method should still call it!
+     * 
+     * @throws Exception on error
+     */
     public void init() throws Exception {
          // check driver version
         Connection connection = dataSource.getConnection();
@@ -70,7 +76,7 @@
      * {@inheritDoc}
      */
     @Override
-    protected void replaceCharacter(StringBuffer escaped, char c) {
+    protected final void replaceCharacter(StringBuffer escaped, char c) {
         escaped.append("_");
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java?rev=815298&r1=815297&r2=815298&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java
Tue Sep 15 12:35:48 2009
@@ -35,10 +35,13 @@
     private final ResultSet resultSet;
 
     /**
-     * @param con
-     * @param stmt
-     * @param rs
-     * @return
+     * Creates a new {@code ResultSet} proxy which closes the given {@code Connection} and
+     * {@code Statement} if it is closed.
+     * 
+     * @param con the associated {@code Connection}
+     * @param stmt the associated {@code Statement}
+     * @param rs the {@code ResultSet} which backs the proxy
+     * @return a {@code ResultSet} proxy
      */
     public static final ResultSet newInstance(Connection con, Statement stmt, ResultSet rs)
{
         ResultSetWrapper proxy = new ResultSetWrapper(con, stmt, rs);



Mime
View raw message