LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  September 2015

HPS-SVN September 2015

Subject:

r3526 - /java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Fri, 4 Sep 2015 21:54:43 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (162 lines)

Author: [log in to unmask]
Date: Fri Sep  4 14:54:39 2015
New Revision: 3526

Log:
Remove unused methods; setup static state in getInstance and resetInstance methods instead of constructor; clear conditions cache between runs.

Modified:
    java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java

Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
 =============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java	(original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java	Fri Sep  4 14:54:39 2015
@@ -11,7 +11,6 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -118,7 +117,10 @@
         if (!ConditionsManager.isSetup() || !(ConditionsManager.defaultInstance() instanceof DatabaseConditionsManager)) {
             logger.finest("creating new DatabaseConditionsManager instance");
             // Create a new instance if necessary, which will install it globally as the default.
-            new DatabaseConditionsManager();
+            DatabaseConditionsManager dbManager = new DatabaseConditionsManager();
+
+            // Register default conditions manager.
+            ConditionsManager.setDefaultConditionsManager(dbManager);
         }
 
         // Get the instance back from the default conditions system and check that the type is correct now.
@@ -156,7 +158,12 @@
      */
     public static synchronized void resetInstance() {
         logger.finest("DatabaseConditionsManager instance is being reset");
-        new DatabaseConditionsManager();
+        
+        // Create a new instance if necessary, which will install it globally as the default.
+        DatabaseConditionsManager dbManager = new DatabaseConditionsManager();
+
+        // Register default conditions manager.
+        ConditionsManager.setDefaultConditionsManager(dbManager);
     }
 
     /**
@@ -277,30 +284,31 @@
     /**
      * Class constructor. Calling this will automatically register this manager as the global default.
      */
-    private DatabaseConditionsManager() {
+    protected DatabaseConditionsManager() {
         
         // Register detector conditions converter.
+        logger.config("registering detector converter");
         this.registerConditionsConverter(new DetectorConditionsConverter());
         
         // Setup connection from system property pointing to a file, if it was set.
+        logger.config("checking for file connection system property");
         this.setupConnectionSystemPropertyFile();
         
         // Setup connection from system property pointing to a resource, if it was set.
+        logger.config("checking for resource connection system property");
         this.setupConnectionSystemPropertyResource();
-        
-        // Register default conditions manager.
-        ConditionsManager.setDefaultConditionsManager(this);
-        
+                
         // Set run to invalid number.
         this.setRun(-1);
         
         // Register conditions converters.
         for (final AbstractConditionsObjectConverter converter : this.converters.values()) {
-            // logger.fine("registering converter for " + converter.getType());
+            logger.config("registering converter for " + converter.getType());
             this.registerConditionsConverter(converter);
         }
         
         // Add the SVT detector setup object as a listener.
+        logger.config("adding SVT setup");
         this.addConditionsListener(this.svtSetup);
     }
 
@@ -410,17 +418,7 @@
     public ConditionsRecordCollection findConditionsRecords(final String name) {
         return getConditionsRecords().findByKey(name);
     }
-
-    /**
-     * Find table information from the collection type.
-     *
-     * @param type the collection type
-     * @return the table information or <code>null</code> if does not exist
-     */
-    public List<TableMetaData> findTableMetaData(final Class<?> type) {
-        return this.tableRegistry.findByCollectionType(type);
-    }
-
+  
     /**
      * Find table information from the name.
      *
@@ -653,8 +651,11 @@
      * @throws ConditionsNotFoundException if there is a conditions system error
      */
     private void initialize(final String detectorName, final int runNumber) throws ConditionsNotFoundException {
-
+        
         logger.config("initializing with detector " + detectorName + " and run " + runNumber);
+                
+        // Clear the conditions cache.
+        this.clearCache();
 
         // Is not configured yet?
         if (!this.isConfigured) {
@@ -894,7 +895,6 @@
             this.isConnected = true;
             openedConnection = true;
         }
-        logger.fine("connection opened successfully");
 
         // Flag to indicate whether an existing connection was used or not.
         return openedConnection;
@@ -1145,33 +1145,5 @@
     public synchronized void unfreeze() {
         this.isFrozen = false;
         logger.info("conditions system unfrozen");
-    }
-
-    /**
-     * Perform a SQL query with an update command like INSERT, DELETE or UPDATE.
-     *
-     * @param query the SQL query string
-     * @return the keys of the rows affected
-     */
-    public List<Integer> updateQuery(final String query) {
-        final boolean openedConnection = this.openConnection();
-        logger.fine("executing SQL update query ..." + '\n' + query);
-        final List<Integer> keys = new ArrayList<Integer>();
-        Statement statement = null;
-        ResultSet resultSet = null;
-        try {
-            statement = this.connection.createStatement();
-            statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
-            resultSet = statement.getGeneratedKeys();
-            while (resultSet.next()) {
-                final int key = resultSet.getInt(1);
-                keys.add(key);
-            }
-        } catch (final SQLException x) {
-            throw new RuntimeException("Error in SQL query: " + query, x);
-        }
-        DatabaseUtilities.cleanup(resultSet);
-        this.closeConnection(openedConnection);
-        return keys;
-    }
+    }    
 }

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use