commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject cvs commit: jakarta-commons-sandbox/mapper/src/share/org/apache/commons/mapper/jdbc JdbcMapperFactoryListener.java
Date Tue, 02 Sep 2003 04:18:20 GMT
dgraham     2003/09/01 21:18:20

  Modified:    mapper/src/share/org/apache/commons/mapper/jdbc
                        JdbcMapperFactoryListener.java
  Log:
  Only call Mapper's setter methods if local variables are not null.  This allows
  the Mapper to initialize some of its properties in its constructor and not
  get overwritten with null by this listener.
  
  Revision  Changes    Path
  1.3       +21 -33    jakarta-commons-sandbox/mapper/src/share/org/apache/commons/mapper/jdbc/JdbcMapperFactoryListener.java
  
  Index: JdbcMapperFactoryListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/mapper/src/share/org/apache/commons/mapper/jdbc/JdbcMapperFactoryListener.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JdbcMapperFactoryListener.java	21 Jun 2003 01:54:05 -0000	1.2
  +++ JdbcMapperFactoryListener.java	2 Sep 2003 04:18:19 -0000	1.3
  @@ -61,13 +61,10 @@
   
   package org.apache.commons.mapper.jdbc;
   
  -import java.util.HashMap;
  -import java.util.Iterator;
   import java.util.Map;
   
   import javax.sql.DataSource;
   
  -import org.apache.commons.mapper.MapperFactory;
   import org.apache.commons.mapper.MapperFactoryEvent;
   import org.apache.commons.mapper.MapperFactoryListener;
   
  @@ -100,8 +97,8 @@
   
       /**
        * Create a new JdbcMapperFactoryListener.
  -     * @param ds A DataSource object that the JdbcMappers returned from this factory
  -     * will use for queries.  
  +     * @param ds A DataSource object that the JdbcMappers returned from this 
  +     * factory will use for queries.  
        */
       public JdbcMapperFactoryListener(DataSource ds) {
           this(ds, null);
  @@ -111,24 +108,22 @@
        * Create a new JdbcMapperFactoryListener.
        * @param ds A DataSource object that JdbcMappers initialized from this 
        * listener will use for queries.
  -     * @param queries A map of query names to SQL queries to pass to the mappers.  
  -     * The keys in this map are case-insensitive.
  +     * @param queries A map of query names to SQL queries to pass to the 
  +     * mappers.  
        */
       public JdbcMapperFactoryListener(DataSource ds, Map queries) {
           super();
  +
           this.ds = ds;
           this.helper = new JdbcHelper(ds);
  -
  -        if (queries != null) {
  -            this.queries = this.uppercaseKeys(queries);
  -        }
  +        this.queries = queries;
       }
   
       /**
  -     * Sets each JdbcMapper's datasource to the instance given in the constructor 
  -     * before it's placed in the cache and returned.  This ignores any Mapper that is
  -     * not a sublcass of JdbcMapper.
  -     * @param event
  +     * Sets each JdbcMapper's datasource to the instance given in the 
  +     * constructor before it's placed in the cache and returned.  This ignores 
  +     * any Mapper that is not a sublcass of <code>JdbcMapper</code>.
  +     * @param event The event containing the Mapper to initialize.
        * @see org.apache.commons.mapper.MapperFactoryListener#mapperCreated(org.apache.commons.mapper.MapperFactoryEvent)
        */
       public void mapperCreated(MapperFactoryEvent event) {
  @@ -138,27 +133,20 @@
   
           JdbcMapper m = (JdbcMapper) event.getMapper();
   
  -        m.setMapperFactory((MapperFactory) event.getSource());
  -        m.setDataSource(this.ds);
  -        m.setHelper(this.helper);
  -        m.setQueries(this.queries);
  -    }
  +        m.setMapperFactory(event.getMapperFactory());
   
  -    /**
  -     * Uppercases key names for case-insensitive lookups.
  -     * @return A Map with uppercased keys from the given Map.
  -     */
  -    private Map uppercaseKeys(Map map) {
  -        Map temp = new HashMap();
  -        Iterator i = map.keySet().iterator();
  -        // copy key value pairs into new map
  -        while (i.hasNext()) {
  -            String key = (String) i.next();
  -            String value = (String) map.get(key);
  -            temp.put(key.toUpperCase(), value);
  +        if (this.ds != null) {
  +            m.setDataSource(this.ds);
  +        }
  +
  +        if (this.helper != null) {
  +            m.setHelper(this.helper);
           }
   
  -        return temp;
  +        if (this.queries != null) {
  +            m.setQueries(this.queries);
  +        }
  +        
       }
   
   }
  
  
  

Mime
View raw message