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 "Moriyoshi Koizumi (JIRA)" <ji...@apache.org> on 2008/11/28 01:26:44 UTC

[jira] Created: (TORQUE-120) Inappropriate dependencies on Torque from TorqueInstance

Inappropriate dependencies on Torque from TorqueInstance
--------------------------------------------------------

                 Key: TORQUE-120
                 URL: https://issues.apache.org/jira/browse/TORQUE-120
             Project: Torque
          Issue Type: Bug
          Components: Runtime
    Affects Versions: 3.3
         Environment: Mac OS X Tiger (10.4.11) / PPC
            Reporter: Moriyoshi Koizumi
             Fix For: 3.3-RC3


I found a number of inappropriate invocations from org.apache.torque.TorqueInstance to static methods of org.apache.torque.Torque. I'm not sure but I suspect this bug was created during the transition from Torque to TorqueInstance.

Index: src/java/org/apache/torque/TorqueInstance.java
===================================================================
--- src/java/org/apache/torque/TorqueInstance.java	(revision 721316)
+++ src/java/org/apache/torque/TorqueInstance.java	(working copy)
@@ -312,7 +312,7 @@
 
         // check that at least the default database has got an adapter.
         Database defaultDatabase
-                = (Database) databases.get(Torque.getDefaultDB());
+                = (Database) databases.get(getDefaultDB());
         if (defaultDatabase == null
             || defaultDatabase.getAdapter() == null)
         {
@@ -323,7 +323,7 @@
                     + "."
                     + Torque.DATABASE_KEY
                     + "."
-                    + Torque.getDefaultDB()
+                    + getDefaultDB()
                     + "."
                     + DB.ADAPTER_KEY;
             log.error(error);
@@ -903,7 +903,7 @@
     public Connection getConnection(String name)
             throws TorqueException
     {
-        if (!Torque.isInit())
+        if (!isInit())
         {
             throw new TorqueException("Torque is not initialized");
         }
@@ -966,7 +966,7 @@
             String password)
             throws TorqueException
     {
-        if (!Torque.isInit())
+        if (!isInit())
         {
             throw new TorqueException("Torque is not initialized");
         }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (TORQUE-120) Inappropriate dependencies on Torque from TorqueInstance

Posted by "Thomas Fischer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TORQUE-120?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Fischer updated TORQUE-120:
----------------------------------

    Fix Version/s:     (was: 3.3-RC3)

> Inappropriate dependencies on Torque from TorqueInstance
> --------------------------------------------------------
>
>                 Key: TORQUE-120
>                 URL: https://issues.apache.org/jira/browse/TORQUE-120
>             Project: Torque
>          Issue Type: Bug
>          Components: Runtime
>    Affects Versions: 3.3
>         Environment: Mac OS X Tiger (10.4.11) / PPC
>            Reporter: Moriyoshi Koizumi
>
> I found a number of inappropriate invocations from org.apache.torque.TorqueInstance to static methods of org.apache.torque.Torque. I'm not sure but I suspect this bug was created during the transition from Torque to TorqueInstance.
> Index: src/java/org/apache/torque/TorqueInstance.java
> ===================================================================
> --- src/java/org/apache/torque/TorqueInstance.java	(revision 721316)
> +++ src/java/org/apache/torque/TorqueInstance.java	(working copy)
> @@ -312,7 +312,7 @@
>  
>          // check that at least the default database has got an adapter.
>          Database defaultDatabase
> -                = (Database) databases.get(Torque.getDefaultDB());
> +                = (Database) databases.get(getDefaultDB());
>          if (defaultDatabase == null
>              || defaultDatabase.getAdapter() == null)
>          {
> @@ -323,7 +323,7 @@
>                      + "."
>                      + Torque.DATABASE_KEY
>                      + "."
> -                    + Torque.getDefaultDB()
> +                    + getDefaultDB()
>                      + "."
>                      + DB.ADAPTER_KEY;
>              log.error(error);
> @@ -903,7 +903,7 @@
>      public Connection getConnection(String name)
>              throws TorqueException
>      {
> -        if (!Torque.isInit())
> +        if (!isInit())
>          {
>              throw new TorqueException("Torque is not initialized");
>          }
> @@ -966,7 +966,7 @@
>              String password)
>              throws TorqueException
>      {
> -        if (!Torque.isInit())
> +        if (!isInit())
>          {
>              throw new TorqueException("Torque is not initialized");
>          }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (TORQUE-120) Inappropriate dependencies on Torque from TorqueInstance

Posted by "Moriyoshi Koizumi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12655104#action_12655104 ] 

Moriyoshi Koizumi commented on TORQUE-120:
------------------------------------------

>From a design perspective, I don't think the instance method should call the static method to check if it's been initialized as long as it's possible that each TorqueInstance instance has a separate class loader, 

> Inappropriate dependencies on Torque from TorqueInstance
> --------------------------------------------------------
>
>                 Key: TORQUE-120
>                 URL: https://issues.apache.org/jira/browse/TORQUE-120
>             Project: Torque
>          Issue Type: Bug
>          Components: Runtime
>    Affects Versions: 3.3
>         Environment: Mac OS X Tiger (10.4.11) / PPC
>            Reporter: Moriyoshi Koizumi
>
> I found a number of inappropriate invocations from org.apache.torque.TorqueInstance to static methods of org.apache.torque.Torque. I'm not sure but I suspect this bug was created during the transition from Torque to TorqueInstance.
> Index: src/java/org/apache/torque/TorqueInstance.java
> ===================================================================
> --- src/java/org/apache/torque/TorqueInstance.java	(revision 721316)
> +++ src/java/org/apache/torque/TorqueInstance.java	(working copy)
> @@ -312,7 +312,7 @@
>  
>          // check that at least the default database has got an adapter.
>          Database defaultDatabase
> -                = (Database) databases.get(Torque.getDefaultDB());
> +                = (Database) databases.get(getDefaultDB());
>          if (defaultDatabase == null
>              || defaultDatabase.getAdapter() == null)
>          {
> @@ -323,7 +323,7 @@
>                      + "."
>                      + Torque.DATABASE_KEY
>                      + "."
> -                    + Torque.getDefaultDB()
> +                    + getDefaultDB()
>                      + "."
>                      + DB.ADAPTER_KEY;
>              log.error(error);
> @@ -903,7 +903,7 @@
>      public Connection getConnection(String name)
>              throws TorqueException
>      {
> -        if (!Torque.isInit())
> +        if (!isInit())
>          {
>              throw new TorqueException("Torque is not initialized");
>          }
> @@ -966,7 +966,7 @@
>              String password)
>              throws TorqueException
>      {
> -        if (!Torque.isInit())
> +        if (!isInit())
>          {
>              throw new TorqueException("Torque is not initialized");
>          }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (TORQUE-120) Inappropriate dependencies on Torque from TorqueInstance

Posted by "Thomas Fischer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12651516#action_12651516 ] 

Thomas Fischer commented on TORQUE-120:
---------------------------------------

I agree that the calls to getDefaultDb() should be on the instance (though it does not make any functional difference, see below)
I am not sure whether the calls to Torque.isInit() should be to the instance, for the following reason:
The TorqueInstance needs to be a singleton, because it keeps track of the Initialisation status of torque, which depends on which Peer classes are loaded by the class loader and which are not. So, there can be only one registered Torquenstance Singleton in a Class loading scope, otherwise Torque will not work correctly (From this it follows that whether one calls Torque.something() or something() from TorqueInstance makes no functional difference). So to find the initialisation status of Torque, I'd think that one should ask the one true registered instance of TorqueInstance whether it is initialized or not, and not any TorqueInstance instance which happens to float around somewhere.
On the other hand, if a container like Spring ensures that only one TorqueInstance exists, reverting the isInit() call to an instance call would make sense.
It seems to me that the division between Torque and TorqueInstance is not based on any concept by now. This is the true thing that needs to be changed. 

> Inappropriate dependencies on Torque from TorqueInstance
> --------------------------------------------------------
>
>                 Key: TORQUE-120
>                 URL: https://issues.apache.org/jira/browse/TORQUE-120
>             Project: Torque
>          Issue Type: Bug
>          Components: Runtime
>    Affects Versions: 3.3
>         Environment: Mac OS X Tiger (10.4.11) / PPC
>            Reporter: Moriyoshi Koizumi
>
> I found a number of inappropriate invocations from org.apache.torque.TorqueInstance to static methods of org.apache.torque.Torque. I'm not sure but I suspect this bug was created during the transition from Torque to TorqueInstance.
> Index: src/java/org/apache/torque/TorqueInstance.java
> ===================================================================
> --- src/java/org/apache/torque/TorqueInstance.java	(revision 721316)
> +++ src/java/org/apache/torque/TorqueInstance.java	(working copy)
> @@ -312,7 +312,7 @@
>  
>          // check that at least the default database has got an adapter.
>          Database defaultDatabase
> -                = (Database) databases.get(Torque.getDefaultDB());
> +                = (Database) databases.get(getDefaultDB());
>          if (defaultDatabase == null
>              || defaultDatabase.getAdapter() == null)
>          {
> @@ -323,7 +323,7 @@
>                      + "."
>                      + Torque.DATABASE_KEY
>                      + "."
> -                    + Torque.getDefaultDB()
> +                    + getDefaultDB()
>                      + "."
>                      + DB.ADAPTER_KEY;
>              log.error(error);
> @@ -903,7 +903,7 @@
>      public Connection getConnection(String name)
>              throws TorqueException
>      {
> -        if (!Torque.isInit())
> +        if (!isInit())
>          {
>              throw new TorqueException("Torque is not initialized");
>          }
> @@ -966,7 +966,7 @@
>              String password)
>              throws TorqueException
>      {
> -        if (!Torque.isInit())
> +        if (!isInit())
>          {
>              throw new TorqueException("Torque is not initialized");
>          }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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