dlr         01/08/20 10:48:55

  Modified:    src/java/org/apache/torque Torque.java
  Log:
  Cleanup and documenation.
  
  Revision  Changes    Path
  1.7       +36 -15    jakarta-turbine-torque/src/java/org/apache/torque/Torque.java
  
  Index: Torque.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/Torque.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- Torque.java       2001/08/15 21:18:54     1.6
  +++ Torque.java       2001/08/20 17:48:55     1.7
  @@ -78,7 +78,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Magn�s ��r Torfason</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
  - * @version $Id: Torque.java,v 1.6 2001/08/15 21:18:54 dlr Exp $
  + * @version $Id: Torque.java,v 1.7 2001/08/20 17:48:55 dlr Exp $
    */
   public class Torque
   {
  @@ -88,6 +88,11 @@
        */
       public static final String DATABASE_DEFAULT = "database.default";
   
  +    /**
  +     * A constant for <code>default</code>.
  +     */
  +    protected static final String DEFAULT_NAME = "default";
  +
       /** The global cache of database maps */
       private static Map dbMaps;
   
  @@ -109,9 +114,19 @@
        */
       private static final String DEFAULT_CATEGORY = "sql";
   
  +    /**
  +     * The logging category.
  +     */
       private static Category category;
  +
  +    /**
  +     * Torque-specific configuration.
  +     */
       private static ExtendedProperties configuration;
   
  +    /**
  +     * The connection pool monitor.
  +     */
       private static Monitor monitor;
   
       /**
  @@ -201,7 +216,7 @@
           throws TorqueException
       {
           return getDatabaseMap(
  -            configuration.getString(DATABASE_DEFAULT,"default"));
  +            configuration.getString(DATABASE_DEFAULT, DEFAULT_NAME));
       }
   
       /**
  @@ -319,11 +334,10 @@
        * @throws TorqueException Any exceptions caught during processing will be
        *         rethrown wrapped into a TorqueException.
        */
  -    public static  DBConnection getConnection()
  +    public static DBConnection getConnection()
           throws Exception
       {
  -        return getConnection(
  -            configuration.getString(DATABASE_DEFAULT,"default"));
  +        return getConnection(getDefaultDB());
       }
   
       /**
  @@ -345,7 +359,7 @@
        * @throws TorqueException Any exceptions caught during processing will be
        *         rethrown wrapped into a TorqueException.
        */
  -    public static  DBConnection getConnection(String name)
  +    public static DBConnection getConnection(String name)
           throws Exception
       {
           // The getPool method ensures the validity of the returned pool.
  @@ -367,7 +381,7 @@
        * @deprecated Database parameters should not be specified each
        * time a DBConnection is fetched from the service.
        */
  -    public static  DBConnection getConnection(String driver,
  +    public static DBConnection getConnection(String driver,
                                         String url,
                                         String username,
                                         String password)
  @@ -508,7 +522,7 @@
       public static DB getDB()
           throws Exception
       {
  -        return getDB(configuration.getString(DATABASE_DEFAULT,"default"));
  +        return getDB(configuration.getString(DATABASE_DEFAULT, DEFAULT_NAME));
       }
   
       /**
  @@ -536,7 +550,8 @@
       private static ConnectionPool getPool()
           throws Exception
       {
  -        return getPool(configuration.getString(DATABASE_DEFAULT,"default"));
  +        return getPool(configuration.getString(DATABASE_DEFAULT,
  +                                               DEFAULT_NAME));
       }
   
       /**
  @@ -648,21 +663,27 @@
           }
       }
   
  -    public static  String getDefaultDB()
  +    /**
  +     * Returns the name of the default database.
  +     */
  +    public static String getDefaultDB()
       {
           if (configuration == null)
           {
  -            return "default";
  +            return DEFAULT_NAME;
           }
  -        return configuration.getString(DATABASE_DEFAULT,"default");
  +        return configuration.getString(DATABASE_DEFAULT, DEFAULT_NAME);
       }
   
  -    public static  String getDefaultMap()
  +    /**
  +     * Returns the name of the default database map.
  +     */
  +    public static String getDefaultMap()
       {
           if (configuration == null)
           {
  -            return "default";
  +            return DEFAULT_NAME;
           }
  -        return configuration.getString(DATABASE_DEFAULT,"default");
  +        return configuration.getString(DATABASE_DEFAULT, DEFAULT_NAME);
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to