db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Rall <...@finemaltcoding.com>
Subject Re: cvs commit: db-torque/src/java/org/apache/torque TorqueSingleton.java
Date Mon, 30 Jun 2003 22:42:45 GMT
I like the improved the diagnostics!  A few other comments below.

henning@apache.org writes:
...
>   - 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
...
>   --- TorqueSingleton.java	24 Jun 2003 09:43:29 -0000	1.6
>   +++ TorqueSingleton.java	30 Jun 2003 22:11:05 -0000	1.7
...
>   @@ -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!");
>   +                }

"adapter configurations" would be better than "adapters configurations".

>                }
>                catch (Exception e)
>                {
>   @@ -272,8 +279,9 @@
>            }
>            else
>            {
>   -            log.warn("There were no adapters in the configuration.");
>   +            log.warn("No Database definitions found!");
>            }
>   +
>        }
>    
>        /**

If a user is hit by this one, they could probably use clue as to where
to define their configuration.  How about adding reference to a web
page with help docs or to a configuration file?

...
>   @@ -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)
>                {

Would a default factory be usable here (e.g. like in the case where
they're using a default data source type)?

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

"keys" is a slightly more descriptive variable name than "it".

>   @@ -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)
>                    {

"maps" is a more descriptive variable name than "it".
-- 

Daniel Rall

Mime
View raw message