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 TorqueSingleton.java
Date Mon, 30 Jun 2003 22:11:05 GMT
henning     2003/06/30 15:11:05

  Modified:    src/java/org/apache/torque TorqueSingleton.java
  Log:
  - replaced some while() loops with iterators with
    for(Iterator ...; it.hasNext();) loops
  - Added clear warnings for
     - databases configured but no adapters set
     - datasource configured but no factories set
     - no databases at all configured
  
  Revision  Changes    Path
  1.7       +26 -15    db-torque/src/java/org/apache/torque/TorqueSingleton.java
  
  Index: TorqueSingleton.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/java/org/apache/torque/TorqueSingleton.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TorqueSingleton.java	24 Jun 2003 09:43:29 -0000	1.6
  +++ TorqueSingleton.java	30 Jun 2003 22:11:05 -0000	1.7
  @@ -246,14 +246,16 @@
           log.debug("Starting initAdapters");
           adapterMap = new HashMap();
           Configuration c = conf.subset("database");
  +
           if (c != null)
           {
  +            boolean foundAdapters = false;
  +
               try
               {
  -                Iterator i = c.getKeys();
  -                while (i.hasNext())
  +                for (Iterator it = c.getKeys(); it.hasNext(); )
                   {
  -                    String key = (String) i.next();
  +                    String key = (String) it.next();
                       if (key.endsWith("adapter"))
                       {
                           String adapter = c.getString(key);
  @@ -261,8 +263,13 @@
                           DB db = DBFactory.create(adapter);
                           // register the adapter for this name
                           adapterMap.put(handle, db);
  +                        foundAdapters = true;
                       }
                   }
  +                if (!foundAdapters)
  +                {
  +                    log.warn("Databases defined but no adapters configurations found!");
  +                }
               }
               catch (Exception e)
               {
  @@ -272,8 +279,9 @@
           }
           else
           {
  -            log.warn("There were no adapters in the configuration.");
  +            log.warn("No Database definitions found!");
           }
  +
       }
   
       /**
  @@ -290,12 +298,13 @@
           Configuration c = conf.subset("dsfactory");
           if (c != null)
           {
  +            boolean foundFactories = false;
  +
               try
               {
  -                Iterator i = c.getKeys();
  -                while (i.hasNext())
  +                for (Iterator it = c.getKeys(); it.hasNext();)
                   {
  -                    String key = (String) i.next();
  +                    String key = (String) it.next();
                       if (key.endsWith("factory"))
                       {
                           String classname = c.getString(key);
  @@ -307,8 +316,13 @@
                                   (DataSourceFactory) dsfClass.newInstance();
                           dsf.initialize(c.subset(handle));
                           dsFactoryMap.put(handle, dsf);
  +                        foundFactories = true;
                       }
                   }
  +                if (!foundFactories)
  +                {
  +                    log.warn("Data Sources configured but no factories found!");
  +                }
               }
               catch (Exception e)
               {
  @@ -406,11 +420,9 @@
           int pref = Torque.MANAGER_PREFIX.length();
           int suff = Torque.MANAGER_SUFFIX.length();
   
  -        Iterator keys = conf.getKeys();
  -
  -        while (keys.hasNext())
  +        for (Iterator it = conf.getKeys(); it.hasNext();)
           {
  -            String key = (String) keys.next();
  +            String key = (String) it.next();
   
               if (key.startsWith(Torque.MANAGER_PREFIX)
                       && key.endsWith(Torque.MANAGER_SUFFIX))
  @@ -562,10 +574,9 @@
       {
           if (dbMaps != null)
           {
  -            Iterator maps = dbMaps.values().iterator();
  -            while (maps.hasNext())
  +            for (Iterator it = dbMaps.values().iterator(); it.hasNext();)
               {
  -                DatabaseMap map = (DatabaseMap) maps.next();
  +                DatabaseMap map = (DatabaseMap) it.next();
                   IDBroker idBroker = map.getIDBroker();
                   if (idBroker != null)
                   {
  
  
  

Mime
View raw message