mpoeschl    02/05/27 05:17:43

  Modified:    src/java/org/apache/torque Torque.java
               src/java/org/apache/torque/dsfactory
                        AbstractDataSourceFactory.java
                        JndiDataSourceFactory.java
  Log:
  remove unused imports
  
  Revision  Changes    Path
  1.61      +22 -36    jakarta-turbine-torque/src/java/org/apache/torque/Torque.java
  
  Index: Torque.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/Torque.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- Torque.java       26 May 2002 04:30:10 -0000      1.60
  +++ Torque.java       27 May 2002 12:17:43 -0000      1.61
  @@ -56,11 +56,6 @@
   
   import java.io.IOException;
   import java.sql.Connection;
  -import javax.sql.DataSource;
  -import java.beans.PropertyDescriptor;
  -import java.beans.PropertyEditorManager;
  -import java.beans.PropertyEditor;
  -import java.lang.reflect.Method;
   import java.io.File;
   import java.util.HashMap;
   import java.util.Enumeration;
  @@ -70,12 +65,6 @@
   import java.util.ArrayList;
   import java.util.Collections;
   import java.util.Properties;
  -import java.util.Hashtable;
  -import java.util.StringTokenizer;
  -import javax.naming.Context;
  -import javax.naming.InitialContext;
  -import javax.naming.NameAlreadyBoundException;
  -import javax.naming.NamingException;
   import org.apache.log4j.Category;
   import org.apache.log4j.PropertyConfigurator;
   import org.apache.log4j.helpers.NullEnumeration;
  @@ -92,9 +81,6 @@
   import org.apache.commons.configuration.PropertiesConfiguration;
   import org.apache.stratum.lifecycle.Configurable;
   import org.apache.stratum.lifecycle.Initializable;
  -import org.apache.commons.beanutils.ConvertUtils;
  -import org.apache.commons.beanutils.PropertyUtils;
  -import org.apache.commons.beanutils.MappedPropertyDescriptor;
   
   /**
    * The implementation of Torque.
  @@ -104,7 +90,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Poeschl</a>
  - * @version $Id: Torque.java,v 1.60 2002/05/26 04:30:10 jmcnally Exp $
  + * @version $Id: Torque.java,v 1.61 2002/05/27 12:17:43 mpoeschl Exp $
    */
   public class Torque implements Initializable, Configurable
   {
  @@ -142,18 +128,18 @@
        */
       private static Map dbMaps;
   
  -    /** 
  -     * The cache of DataSourceFactory's 
  +    /**
  +     * The cache of DataSourceFactory's
        */
       private static Map dsFactoryMap;
   
  -    /** 
  -     * The cache of datasources 
  +    /**
  +     * The cache of datasources
        */
       private static Map dsMap;
   
  -    /** 
  -     * The cache of DB adapter keys 
  +    /**
  +     * The cache of DB adapter keys
        */
       private static Map adapterMap;
   
  @@ -258,17 +244,17 @@
       private static final void initAdapters(Configuration configuration)
           throws TorqueException
       {
  -        category.debug("Starting initAdapters"); 
  +        category.debug("Starting initAdapters");
           adapterMap = new HashMap();
           Configuration c = configuration.subset("database");
  -        if (c != null) 
  -        {        
  +        if (c != null)
  +        {
           try
           {
               Iterator i = c.getKeys();
               while (i.hasNext())
               {
  -                String key = (String)i.next();                
  +                String key = (String)i.next();
                   if (key.endsWith("adapter"))
                   {
                       String adapter = c.getString(key);
  @@ -284,37 +270,37 @@
               category.error("", e);
               throw new TorqueException(e);
           }
  -            
  +
           }
  -        else 
  +        else
           {
               category.warn("There were no adapters in the configuration.");
  -        }        
  +        }
       }
   
       private static void initDataSourceFactories(Configuration configuration)
           throws TorqueException
       {
  -        category.debug("Starting initDSF"); 
  +        category.debug("Starting initDSF");
           dsFactoryMap = new HashMap();
           Configuration c = configuration.subset("dsfactory");
  -        if (c != null) 
  +        if (c != null)
           {
               try
               {
                   Iterator i = c.getKeys();
                   while (i.hasNext())
                   {
  -                    String key = (String)i.next();                
  +                    String key = (String)i.next();
                       if (key.endsWith("factory"))
                       {
                           String classname = c.getString(key);
                           String handle = key.substring(0, key.indexOf('.'));
  -                        category.debug("handle: " + handle + 
  +                        category.debug("handle: " + handle +
                                          " DataSourceFactory: " + classname);
  -                        
  +
                           Class dsfClass = Class.forName(classname);
  -                        DataSourceFactory dsf = 
  +                        DataSourceFactory dsf =
                               (DataSourceFactory)dsfClass.newInstance();
                           dsf.initialize(c.subset(handle));
                           dsFactoryMap.put(handle, dsf);
  @@ -708,7 +694,7 @@
           try
           {
               String key = getDatabaseProperty(name, "driver");
  -            if ( key == null || key.length() == 0 ) 
  +            if ( key == null || key.length() == 0 )
               {
                   key = getDatabaseProperty(name, "adapter");
               }
  @@ -788,7 +774,7 @@
        *         rethrown wrapped into a TorqueException.
        */
       public static Connection getConnection()
  -        throws TorqueException, java.sql.SQLException, 
  +        throws TorqueException, java.sql.SQLException,
                  javax.naming.NamingException
       {
           return getConnection(getDefaultDB());
  
  
  
  1.2       +10 -46    
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractDataSourceFactory.java    26 May 2002 04:30:10 -0000      1.1
  +++ AbstractDataSourceFactory.java    27 May 2002 12:17:43 -0000      1.2
  @@ -54,43 +54,9 @@
    * <http://www.apache.org/>.
    */
   
  -import java.io.IOException;
  -import java.sql.Connection;
  -import javax.sql.DataSource;
  -import java.beans.PropertyDescriptor;
  -import java.beans.PropertyEditorManager;
  -import java.beans.PropertyEditor;
  -import java.lang.reflect.Method;
  -import java.io.File;
  -import java.util.HashMap;
  -import java.util.Enumeration;
   import java.util.Iterator;
  -import java.util.Map;
  -import java.util.List;
  -import java.util.ArrayList;
  -import java.util.Collections;
  -import java.util.Properties;
  -import java.util.Hashtable;
  -import java.util.StringTokenizer;
  -import javax.naming.Context;
  -import javax.naming.InitialContext;
  -import javax.naming.NameAlreadyBoundException;
  -import javax.naming.NamingException;
   import org.apache.log4j.Category;
  -import org.apache.log4j.PropertyConfigurator;
  -import org.apache.log4j.helpers.NullEnumeration;
  -import org.apache.torque.adapter.DB;
  -import org.apache.torque.adapter.DBFactory;
  -import org.apache.torque.map.DatabaseMap;
  -import org.apache.torque.map.TableMap;
  -import org.apache.torque.oid.IDGeneratorFactory;
  -import org.apache.torque.oid.IDBroker;
  -import org.apache.torque.util.BasePeer;
  -import org.apache.torque.manager.AbstractBaseManager;
   import org.apache.commons.configuration.Configuration;
  -import org.apache.commons.configuration.PropertiesConfiguration;
  -import org.apache.stratum.lifecycle.Configurable;
  -import org.apache.stratum.lifecycle.Initializable;
   import org.apache.commons.beanutils.ConvertUtils;
   import org.apache.commons.beanutils.PropertyUtils;
   import org.apache.commons.beanutils.MappedPropertyDescriptor;
  @@ -100,7 +66,7 @@
    * package.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>John McNally</a>
  - * @version $Id: AbstractDataSourceFactory.java,v 1.1 2002/05/26 04:30:10 jmcnally 
Exp $
  + * @version $Id: AbstractDataSourceFactory.java,v 1.2 2002/05/27 12:17:43 mpoeschl 
Exp $
    */
   abstract class AbstractDataSourceFactory
   {
  @@ -110,8 +76,7 @@
       protected static Category category =
           Category.getInstance("org.apache.torque");
   
  -    protected void setProperty(String property, Configuration c, 
  -                                    Object ds)
  +    protected void setProperty(String property, Configuration c, Object ds)
           throws Exception
       {
           String key = property;
  @@ -119,11 +84,11 @@
           int dot = property.indexOf('.');
           try
           {
  -            if ( dot > 0 )
  +            if (dot > 0)
               {
  -                property = property.substring(0, dot);                
  +                property = property.substring(0, dot);
   
  -                MappedPropertyDescriptor mappedPD = 
  +                MappedPropertyDescriptor mappedPD =
                       new MappedPropertyDescriptor(property, dsClass);
                   Class propertyType = mappedPD.getMappedPropertyType();
                   Configuration subProps = c.subset(property);
  @@ -131,18 +96,18 @@
                   Iterator j = subProps.getKeys();
                   while (j.hasNext())
                   {
  -                    String subProp = (String)j.next();
  +                    String subProp = (String) j.next();
                       String propVal = subProps.getString(subProp);
                       Object value = ConvertUtils.convert(propVal, propertyType);
                       PropertyUtils
                           .setMappedProperty(ds, property, subProp, value);
                   }
               }
  -            else 
  +            else
               {
  -                Class propertyType = 
  +                Class propertyType =
                       PropertyUtils.getPropertyType(ds, property);
  -                Object value = 
  +                Object value =
                       ConvertUtils.convert(c.getString(property), propertyType);
                   PropertyUtils.setSimpleProperty(ds, property, value);
               }
  @@ -151,10 +116,9 @@
           {
               category.error("Property: " + property + " value: "
                              + c.getString(key) +
  -                           " is not supported by DataSource: " + 
  +                           " is not supported by DataSource: " +
                              ds.getClass().getName());
               throw e;
           }
       }
  -
   }
  
  
  
  1.2       +39 -61    
jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
  
  Index: JndiDataSourceFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JndiDataSourceFactory.java        26 May 2002 04:30:10 -0000      1.1
  +++ JndiDataSourceFactory.java        27 May 2002 12:17:43 -0000      1.2
  @@ -54,49 +54,27 @@
    * <http://www.apache.org/>.
    */
   
  -import java.io.IOException;
  -import java.sql.Connection;
   import javax.sql.DataSource;
  -import java.beans.PropertyDescriptor;
  -import java.beans.PropertyEditorManager;
  -import java.beans.PropertyEditor;
  -import java.lang.reflect.Method;
  -import java.io.File;
  -import java.util.HashMap;
  -import java.util.Enumeration;
   import java.util.Iterator;
   import java.util.Map;
  -import java.util.List;
  -import java.util.ArrayList;
  -import java.util.Collections;
  -import java.util.Properties;
   import java.util.Hashtable;
   import java.util.StringTokenizer;
   import javax.naming.Context;
   import javax.naming.InitialContext;
   import javax.naming.NameAlreadyBoundException;
   import javax.naming.NamingException;
  -import org.apache.log4j.Category;
  -import org.apache.log4j.PropertyConfigurator;
  -import org.apache.log4j.helpers.NullEnumeration;
   import org.apache.commons.configuration.Configuration;
  -import org.apache.commons.configuration.PropertiesConfiguration;
  -import org.apache.stratum.lifecycle.Configurable;
  -import org.apache.stratum.lifecycle.Initializable;
  -import org.apache.commons.beanutils.ConvertUtils;
  -import org.apache.commons.beanutils.PropertyUtils;
  -import org.apache.commons.beanutils.MappedPropertyDescriptor;
   import org.apache.torque.TorqueException;
   
   /**
    * A factory that looks up the DataSource from JNDI.  It is also able
  - * to deploy the DataSource based on properties found in the 
  + * to deploy the DataSource based on properties found in the
    * configuration.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>John McNally</a>
  - * @version $Id: JndiDataSourceFactory.java,v 1.1 2002/05/26 04:30:10 jmcnally Exp $
  + * @version $Id: JndiDataSourceFactory.java,v 1.2 2002/05/27 12:17:43 mpoeschl Exp $
    */
  -public class JndiDataSourceFactory 
  +public class JndiDataSourceFactory
       extends AbstractDataSourceFactory
       implements DataSourceFactory
   {
  @@ -112,7 +90,7 @@
           DataSource ds = null;
           try
           {
  -            ds = ((DataSource)ctx.lookup(path));
  +            ds = ((DataSource) ctx.lookup(path));
           }
           catch (Exception e)
           {
  @@ -127,7 +105,7 @@
        * @throws TorqueException Any exceptions caught during processing will be
        *         rethrown wrapped into a TorqueException.
        */
  -    public void initialize(Configuration configuration) 
  +    public void initialize(Configuration configuration)
           throws TorqueException
       {
           if (configuration == null)
  @@ -135,7 +113,7 @@
               throw new TorqueException("Torque cannot be initialized without " +
                   "a valid configuration. Please check the log files " +
                       "for further details.");
  -        }        
  +        }
           initJNDI(configuration);
           initDataSource(configuration);
       }
  @@ -144,10 +122,10 @@
       private void initJNDI(Configuration configuration)
           throws TorqueException
       {
  -        category.debug("Starting initJNDI"); 
  +        category.debug("Starting initJNDI");
           Hashtable env = null;
           Configuration c = configuration.subset("jndi");
  -        if (c == null) 
  +        if (c == null)
           {
               throw new TorqueException("JndiDataSourceFactory requires a jndi "
                   + "path property to lookup the DataSource in JNDI.");
  @@ -157,27 +135,28 @@
               Iterator i = c.getKeys();
               while (i.hasNext())
               {
  -                String key = (String)i.next();                
  +                String key = (String) i.next();
                   if (key.equals("path"))
                   {
                       path = c.getString(key);
                       category.debug("JNDI path: " + path);
                   }
  -                else                 {
  -                    if (env == null) 
  +                else
  +                {
  +                    if (env == null)
                       {
                           env = new Hashtable();
                       }
                       String value = c.getString(key);
  -                    env.put(key, value); 
  +                    env.put(key, value);
                       category.debug("Set jndi property: " + key + "=" + value);
                   }
               }
  -            if (env == null) 
  +            if (env == null)
               {
                   ctx = new InitialContext();
               }
  -            else 
  +            else
               {
                   ctx = new InitialContext(env);
               }
  @@ -188,47 +167,46 @@
           {
               category.error("", e);
               throw new TorqueException(e);
  -        }        
  +        }
       }
   
       private void initDataSource(Configuration configuration)
           throws TorqueException
       {
  -        category.debug("Starting initDataSources"); 
  +        category.debug("Starting initDataSources");
           Configuration c = configuration.subset("datasource");
           try
           {
  -            if (c != null) 
  -            {            
  +            if (c != null)
  +            {
                   Object ds = null;
                   Iterator i = c.getKeys();
                   while (i.hasNext())
                   {
  -                    String key = (String)i.next();
  +                    String key = (String) i.next();
                       if (key.equals("classname"))
                       {
                           String classname = c.getString(key);
  -                        category.debug("Datasource class: "+classname);
  +                        category.debug("Datasource class: " + classname);
   
                           Class dsClass = Class.forName(classname);
                           ds = dsClass.newInstance();
                       }
  -                    else 
  +                    else
                       {
  -                        category.debug("Setting datasource property: " 
  -                                       + key);
  +                        category.debug("Setting datasource property: " + key);
                           setProperty(key, c, ds);
                       }
                   }
   
                   bindDStoJndi(ctx, path, ds);
  -            }            
  +            }
           }
           catch (Exception e)
           {
               category.error("", e);
               throw new TorqueException(e);
  -        }    
  +        }
       }
   
       private void debugCtx(Context ctx)
  @@ -237,61 +215,61 @@
           category.debug("InitialContext -------------------------------");
           Map env = ctx.getEnvironment();
           Iterator qw = env.keySet().iterator();
  -        category.debug("Environment properties:" + env.size() );
  -        while ( qw.hasNext() ) 
  +        category.debug("Environment properties:" + env.size());
  +        while ( qw.hasNext() )
           {
               Object prop = qw.next();
  -            category.debug("    " + prop + ": " + env.get(prop) );
  +            category.debug("    " + prop + ": " + env.get(prop));
           }
           category.debug("----------------------------------------------");
       }
   
  -    private void bindDStoJndi(Context ctx, String path, Object ds) 
  +    private void bindDStoJndi(Context ctx, String path, Object ds)
           throws Exception
       {
           debugCtx(ctx);
   
           // add subcontexts, if not added already
           int start = path.indexOf(':') + 1;
  -        if ( start > 0 ) 
  +        if ( start > 0 )
           {
               path = path.substring(start);
           }
           StringTokenizer st = new StringTokenizer(path, "/");
  -        while ( st.hasMoreTokens() ) 
  +        while ( st.hasMoreTokens() )
           {
               String subctx = st.nextToken();
  -            if ( st.hasMoreTokens() ) 
  +            if ( st.hasMoreTokens() )
               {
                   try
                   {
                       ctx.createSubcontext(subctx);
  -                    category.debug("Added sub context: "+subctx); 
  +                    category.debug("Added sub context: " + subctx);
                   }
  -                catch(NameAlreadyBoundException nabe)
  +                catch (NameAlreadyBoundException nabe)
                   {
                       // ignore
                   }
  -                catch(NamingException ne)
  +                catch (NamingException ne)
                   {
                       // even though there is a specific exception
                       // for this condition, some implementations
                       // throw the more general one.
                       /*
  -                      if (ne.getMessage().indexOf("already bound") == -1 ) 
  +                      if (ne.getMessage().indexOf("already bound") == -1 )
                         {
                         throw ne;
                         }
                       */
                       // ignore
                   }
  -                ctx = (Context)ctx.lookup(subctx);
  +                ctx = (Context) ctx.lookup(subctx);
               }
  -            else 
  +            else
               {
                   // not really a subctx, it is the ds name
                   ctx.bind(subctx, ds);
  -            }                        
  +            }
           }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to