db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henn...@apache.org
Subject cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/pool TorqueClassicDataSource.java
Date Thu, 09 Jan 2003 15:25:09 GMT
henning     2003/01/09 07:25:08

  Modified:    src/java/org/apache/torque/dsfactory
                        AbstractDataSourceFactory.java
                        Jdbc2PoolDataSourceFactory.java
                        TorqueDataSourceFactory.java
               src/java/org/apache/torque/pool TorqueClassicDataSource.java
  Log:
  Moved the applyConfiguration Method into the Abstract base class.
  Made the jdbc2 factory also use the applyConfiguration method.
  
  Fixed the comment on TorqueDataSourceFactory.
  
  Added yours truly to the authors list of some files.
  
  Revision  Changes    Path
  1.6       +35 -1     jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java
  
  Index: AbstractDataSourceFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractDataSourceFactory.java	9 Jan 2003 13:25:03 -0000	1.5
  +++ AbstractDataSourceFactory.java	9 Jan 2003 15:25:08 -0000	1.6
  @@ -60,12 +60,14 @@
   import org.apache.commons.beanutils.ConvertUtils;
   import org.apache.commons.beanutils.PropertyUtils;
   import org.apache.commons.beanutils.MappedPropertyDescriptor;
  +import org.apache.torque.TorqueException;
   
   /**
    * A class that contains common functionality of the factories in this
    * package.
    *
    * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
  + * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
   public abstract class AbstractDataSourceFactory
  @@ -150,6 +152,38 @@
                   + " is not supported by DataSource: "
                   + ds.getClass().getName());
               throw e;
  +        }
  +    }
  +
  +    /**
  +     * Iterate over a Configuration subset and apply all
  +     * properties to a passed object which must contain Bean
  +     * setter and getter
  +     *
  +     * @param c The configuration subset
  +     * @param o The object to apply the properties to
  +     * @throws TorqueException if a property set fails
  +     */
  +    protected void applyConfiguration(Configuration c, Object o)
  +        throws TorqueException
  +    {
  +        category.debug("applyConfiguration(" + c + ", " + o + ")");
  +        
  +        if(c != null)
  +        {
  +            try
  +            {
  +                for (Iterator i = c.getKeys(); i.hasNext();)
  +                {
  +                    String key = (String) i.next();
  +                    setProperty(key, c, o);
  +                }
  +            }
  +            catch (Exception e)
  +            {
  +                category.error(e);
  +                throw new TorqueException(e);
  +            }
           }
       }
   }
  
  
  
  1.5       +10 -34    jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java
  
  Index: Jdbc2PoolDataSourceFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Jdbc2PoolDataSourceFactory.java	27 Nov 2002 11:43:15 -0000	1.4
  +++ Jdbc2PoolDataSourceFactory.java	9 Jan 2003 15:25:08 -0000	1.5
  @@ -71,6 +71,7 @@
    * configuration.
    *
    * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
  + * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
   public class Jdbc2PoolDataSourceFactory
  @@ -123,22 +124,10 @@
       {
           category.debug("Starting initCPDS");
           ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
  -        Configuration c = configuration.subset("connection");
  -        try
  -        {
  -            Iterator i = c.getKeys();
  -            while (i.hasNext())
  -            {
  -                String key = (String) i.next();
  -                category.debug("Setting datasource property: " + key);
  -                setProperty(key, c, cpds);
  -            }
  -        }
  -        catch (Exception e)
  -        {
  -            category.error("", e);
  -            throw new TorqueException(e);
  -        }
  +        Configuration c = null;
  +
  +        c = configuration.subset("connection");
  +        applyConfiguration(c, cpds);
           return cpds;
       }
   
  @@ -154,23 +143,10 @@
       {
           category.debug("Starting initTorqueClassic");
           Jdbc2PoolDataSource ds = new Jdbc2PoolDataSource();
  -        Configuration c = configuration.subset("pool");
  -        try
  -        {
  -            Iterator i = c.getKeys();
  -            while (i.hasNext())
  -            {
  -                String key = (String) i.next();
  -                category.debug("Setting datasource property: "
  -                               + key);
  -                setProperty(key, c, ds);
  -            }
  -        }
  -        catch (Exception e)
  -        {
  -            category.error("", e);
  -            throw new TorqueException(e);
  -        }
  +        Configuration c = null;
  +
  +        c = configuration.subset("pool");
  +        applyConfiguration(c, ds);
           return ds;
       }
   }
  
  
  
  1.7       +3 -37     jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/TorqueDataSourceFactory.java
  
  Index: TorqueDataSourceFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/TorqueDataSourceFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TorqueDataSourceFactory.java	9 Jan 2003 13:25:03 -0000	1.6
  +++ TorqueDataSourceFactory.java	9 Jan 2003 15:25:08 -0000	1.7
  @@ -66,11 +66,10 @@
   import org.apache.torque.pool.TorqueClassicDataSource;
   
   /**
  - * A factory that looks up the DataSource from JNDI.  It is also able
  - * to deploy the DataSource based on properties found in the
  - * configuration.
  + * A factory that uses the "old" Torque Pools for fetching a DataSource.
    *
    * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
  + * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
   public class TorqueDataSourceFactory
  @@ -149,38 +148,5 @@
           c = configuration.subset("pool");
           applyConfiguration(c, ds);
           return ds;
  -    }
  -
  -
  -    /**
  -     * Iterate over a Configuration subset and apply all
  -     * properties to a passed object which must contain Bean
  -     * setter and getter
  -     *
  -     * @param c The configuration subset
  -     * @param o The object to apply the properties to
  -     * @throws TorqueException if a property set fails
  -     */
  -    private void applyConfiguration(Configuration c, Object o)
  -        throws TorqueException
  -    {
  -        category.debug("applyConfiguration(" + c + ", " + o + ")");
  -        
  -        if(c != null)
  -        {
  -            try
  -            {
  -                for (Iterator i = c.getKeys(); i.hasNext();)
  -                {
  -                    String key = (String) i.next();
  -                    setProperty(key, c, o);
  -                }
  -            }
  -            catch (Exception e)
  -            {
  -                category.error(e);
  -                throw new TorqueException(e);
  -            }
  -        }
       }
   }
  
  
  
  1.8       +2 -1      jakarta-turbine-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java
  
  Index: TorqueClassicDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TorqueClassicDataSource.java	9 Jan 2003 13:38:54 -0000	1.7
  +++ TorqueClassicDataSource.java	9 Jan 2003 15:25:08 -0000	1.8
  @@ -80,6 +80,7 @@
    * Torque's default connection pool DataSource
    *
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
  + * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
   public class TorqueClassicDataSource
  
  
  

Mime
View raw message