logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1617397 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java
Date Tue, 12 Aug 2014 02:04:39 GMT
Author: mattsicker
Date: Tue Aug 12 02:04:38 2014
New Revision: 1617397

URL: http://svn.apache.org/r1617397
Log:
Singleton pattern

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java?rev=1617397&r1=1617396&r2=1617397&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java
Tue Aug 12 02:04:38 2014
@@ -36,7 +36,6 @@ import org.apache.logging.log4j.core.uti
  * An {@link AbstractDatabaseManager} implementation for relational databases accessed via
JDBC.
  */
 public final class JdbcDatabaseManager extends AbstractDatabaseManager {
-    private static final JDBCDatabaseManagerFactory FACTORY = new JDBCDatabaseManagerFactory();
 
     private final List<Column> columns;
     private final ConnectionSource connectionSource;
@@ -174,10 +173,19 @@ public final class JdbcDatabaseManager e
                                                              final ColumnConfig[] columnConfigs)
{
 
         return AbstractDatabaseManager.getManager(
-                name, new FactoryData(bufferSize, connectionSource, tableName, columnConfigs),
FACTORY
+                name, new FactoryData(bufferSize, connectionSource, tableName, columnConfigs),
getFactory()
         );
     }
 
+    // the usual lazy singleton
+    private static class Holder {
+        private static final JDBCDatabaseManagerFactory INSTANCE = new JDBCDatabaseManagerFactory();
+    }
+
+    private static JDBCDatabaseManagerFactory getFactory() {
+        return Holder.INSTANCE;
+    }
+
     /**
      * Encapsulates data that {@link JDBCDatabaseManagerFactory} uses to create managers.
      */



Mime
View raw message