db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henn...@apache.org
Subject cvs commit: db-torque/src/java/org/apache/torque/dsfactory Jdbc2PoolDataSourceFactory.java
Date Thu, 24 Jul 2003 10:37:59 GMT
henning     2003/07/24 03:37:59

  Modified:    src/java/org/apache/torque/dsfactory
                        Jdbc2PoolDataSourceFactory.java
  Log:
  Make the Factory more robust if the global configuration returns null
  (which actually points to an error, but it should not throw NPEs).
  
  Revision  Changes    Path
  1.10      +29 -12    db-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java
  
  Index: Jdbc2PoolDataSourceFactory.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Jdbc2PoolDataSourceFactory.java	14 May 2003 19:38:04 -0000	1.9
  +++ Jdbc2PoolDataSourceFactory.java	24 Jul 2003 10:37:58 -0000	1.10
  @@ -125,13 +125,22 @@
       {
           log.debug("Starting initCPDS");
           ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
  -        Configuration c = null;
  +        Configuration c = Torque.getConfiguration();
   
  -        c = Torque.getConfiguration().subset(DEFAULT_CONNECTION_KEY);
  -        applyConfiguration(c, cpds);
  -
  -        c = configuration.subset(CONNECTION_KEY);
  -        applyConfiguration(c, cpds);
  +        if (c == null)
  +        {
  +            log.warn("Global Configuration not set,"
  +                    + " no Default connection pool data source configured!");
  +        }
  +        else
  +        {
  +            Configuration conf = c.subset(DEFAULT_CONNECTION_KEY);
  +            applyConfiguration(conf, cpds);
  +        }
  +            
  +        Configuration conf = configuration.subset(CONNECTION_KEY);
  +        applyConfiguration(conf, cpds);
  +        
           return cpds;
       }
   
  @@ -147,13 +156,21 @@
       {
           log.debug("Starting initJdbc2Pool");
           Jdbc2PoolDataSource ds = new Jdbc2PoolDataSource();
  -        Configuration c = null;
  +        Configuration c = Torque.getConfiguration();
   
  -        c = Torque.getConfiguration().subset(DEFAULT_POOL_KEY);
  -        applyConfiguration(c, ds);
  +        if (c == null)
  +        {
  +            log.warn("Global Configuration not set,"
  +                    + " no Default pool data source configured!");
  +        }
  +        else
  +        {
  +            Configuration conf = c.subset(DEFAULT_POOL_KEY);
  +            applyConfiguration(conf, ds);
  +        }
   
  -        c = configuration.subset(POOL_KEY);
  -        applyConfiguration(c, ds);
  +        Configuration conf = configuration.subset(POOL_KEY);
  +        applyConfiguration(conf, ds);
           return ds;
       }
   }
  
  
  

---------------------------------------------------------------------
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