db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r493492 - in /db/torque: runtime/trunk/src/java/org/apache/torque/TorqueInstance.java runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java site/trunk/xdocs/changes.xml
Date Sat, 06 Jan 2007 15:57:45 GMT
Author: tv
Date: Sat Jan  6 07:57:44 2007
New Revision: 493492

URL: http://svn.apache.org/viewvc?view=rev&rev=493492
Log:
Allow repeated lookups to the Torque Avalon Component. The component now
registers the existing MapBuilders with the new instance so that they are
re-built during initialization. This is considered a temporary hack until
the static constructors of the generated Peer classes go away.

Modified:
    db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java
    db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java
    db/torque/site/trunk/xdocs/changes.xml

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java?view=diff&rev=493492&r1=493491&r2=493492
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java Sat Jan  6 07:57:44
2007
@@ -783,6 +783,17 @@
     }
 
     /**
+     * Get the registered MapBuilders
+     *
+     * @return the MapBuilder cache
+     * 
+     */
+    public Map getMapBuilders()
+    {
+        return mapBuilderCache;
+    }
+
+    /**
      * Register a MapBuilder
      *
      * @param className the MapBuilder

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java?view=diff&rev=493492&r1=493491&r2=493492
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java Sat Jan
 6 07:57:44 2007
@@ -20,9 +20,11 @@
  */
 
 import java.io.File;
+import java.util.Iterator;
+import java.util.Map;
 
+import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.activity.Startable;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -31,7 +33,7 @@
 import org.apache.avalon.framework.context.Contextualizable;
 import org.apache.avalon.framework.logger.LogEnabled;
 import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.avalon.framework.thread.SingleThreaded;
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.TorqueInstance;
 
@@ -50,8 +52,8 @@
                    Configurable,
                    Initializable,
                    Contextualizable,
-                   Startable,
-                   ThreadSafe
+                   Disposable,
+                   SingleThreaded
 {
     /** The Avalon Application Root */
     private String appRoot = null;
@@ -62,18 +64,6 @@
     /** The configuration file name. */
     private String configFile = null;
 
-
-    /**
-     * Creates a new instance.  Default constructor used by Avalon.
-     */
-    public TorqueComponent()
-    {
-        super();
-
-        // Provide the singleton instance to the static accessor
-        org.apache.torque.Torque.setInstance(this);
-    }
-
     /*
      * ========================================================================
      *
@@ -171,23 +161,34 @@
             throws Exception
     {
         getLogger().debug("initialize()");
-        init(configFile);
-    }
+        
+        TorqueInstance instance = org.apache.torque.Torque.getInstance();
+        
+        // Check if another singleton is already running 
+        if (instance.isInit())
+        {
+            Map mapBuilders = instance.getMapBuilders();
+            
+            // Copy the registered MapBuilders and take care that they will be built again
+            for (Iterator  i = mapBuilders.keySet().iterator(); i.hasNext();)
+            {
+                String className = (String)i.next();
+                registerMapBuilder(className);
+            }
+        }
+        
+        // Provide the singleton instance to the static accessor
+        org.apache.torque.Torque.setInstance(this);
 
-    /**
-     * @see org.apache.avalon.framework.activity.Startable#start()
-     */
-    public void start()
-    {
-        getLogger().debug("start()");
+        init(configFile);
     }
 
     /**
-     * @see org.apache.avalon.framework.activity.Startable#stop()
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
-    public void stop()
+    public void dispose()
     {
-        getLogger().debug("stop()");
+        getLogger().debug("dispose()");
         try
         {
             shutdown();

Modified: db/torque/site/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/changes.xml?view=diff&rev=493492&r1=493491&r2=493492
==============================================================================
--- db/torque/site/trunk/xdocs/changes.xml (original)
+++ db/torque/site/trunk/xdocs/changes.xml Sat Jan  6 07:57:44 2007
@@ -32,6 +32,17 @@
   <body>
 
   <release version="3.3" date="in SVN">
+    <action type="fix" dev="tv" issue="TORQUE-68">
+      Allow repeated lookups to the Torque Avalon Component. The component now
+      registers the existing MapBuilders with the new instance so that they are
+      re-built during initialization. This is considered a temporary hack until
+      the static constructors of the generated Peer classes go away.
+    </action>
+    <action type="update" dev="tv">
+      Centralized the handling of MapBuilders in the TorqueInstance class. This
+      allows for repeated initialization of different instances of Torque. The
+      method BasePeer.getMapBuilder(className) is now deprecated.
+    </action>
     <action type="fix" dev="tfischer">
       Set autocommit=true as default for the sqlexec task in the maven 2 plugin.
       Some databases (e.g. postgresql) need this to proceed if a statement



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


Mime
View raw message