You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2011/07/06 16:06:03 UTC

svn commit: r1143422 - in /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque: Torque.java TorqueInstance.java

Author: tfischer
Date: Wed Jul  6 14:06:03 2011
New Revision: 1143422

URL: http://svn.apache.org/viewvc?rev=1143422&view=rev
Log:
TORQUE-115
- Moved removal of torque prefix in configuration from initialize() to setConfiguration() method
- throw Exception on initialization if Torque is already initialized

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/Torque.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/Torque.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/Torque.java?rev=1143422&r1=1143421&r2=1143422&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/Torque.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/Torque.java Wed Jul  6 14:06:03 2011
@@ -166,8 +166,12 @@ public class Torque
      * Sets the configuration for Torque and all dependencies.
      *
      * @param conf the Configuration
+     * 
+     * @throws TorqueException if the configuration does not contain
+     *         any keys starting with <code>Torque.TORQUE_KEY</code>.
      */
     public static void setConfiguration(Configuration conf)
+            throws TorqueException
     {
         getInstance().setConfiguration(conf);
     }

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java?rev=1143422&r1=1143421&r2=1143422&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java Wed Jul  6 14:06:03 2011
@@ -114,9 +114,8 @@ public class TorqueInstance
     /**
      * Initializes this instance of Torque.
      *
-     * @see org.apache.stratum.lifecycle.Initializable
-     * @throws TorqueException Any exceptions caught during processing will be
-     *         rethrown wrapped into a TorqueException.
+     * @throws TorqueException if Torque is already initialized 
+     *         or an error during initialization occurs.
      */
     private synchronized void initialize() throws TorqueException
     {
@@ -124,8 +123,8 @@ public class TorqueInstance
 
         if (isInit)
         {
-            log.debug("Multiple initializations of Torque attempted");
-            return;
+            throw new TorqueException(
+                    "Multiple initializations of Torque attempted");
         }
 
         if (conf == null || conf.isEmpty())
@@ -141,17 +140,6 @@ public class TorqueInstance
         // properties that are contained in the configuration. First
         // look for properties that are in the "torque" namespace.
 
-        Configuration subConf = conf.subset(Torque.TORQUE_KEY);
-        if (subConf == null || subConf.isEmpty())
-        {
-            String error = ("Invalid configuration. No keys starting with "
-                    + Torque.TORQUE_KEY
-                    + " found in configuration");
-            log.error(error);
-            throw new TorqueException(error);
-        }
-        setConfiguration(subConf);
-
         initDefaultDbName(conf);
         initAdapters(conf);
         initDataSourceFactories(conf);
@@ -580,15 +568,29 @@ public class TorqueInstance
 
     /**
      * Sets the configuration for Torque and all dependencies.
-     * The prefix <code>TORQUE_KEY</code> needs to be removed from the
+     * The prefix <code>TORQUE_KEY</code> will be removed from the
      * configuration keys for the provided configuration.
      *
      * @param conf the Configuration.
+     *
+     * @throws TorqueException if the configuration does not contain
+     *         any keys starting with <code>Torque.TORQUE_KEY</code>.
      */
     public void setConfiguration(Configuration conf)
+            throws TorqueException
     {
         log.debug("setConfiguration(" + conf + ")");
-        this.conf = conf;
+
+        Configuration subConf = conf.subset(Torque.TORQUE_KEY);
+        if (subConf == null || subConf.isEmpty())
+        {
+            String error = ("Invalid configuration. No keys starting with "
+                    + Torque.TORQUE_KEY
+                    + " found in configuration");
+            log.error(error);
+            throw new TorqueException(error);
+        }
+        this.conf = subConf;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org