You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mp...@apache.org on 2002/02/06 16:18:56 UTC

cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

mpoeschl    02/02/06 07:18:56

  Modified:    src/java/org/apache/torque Torque.java
               src/java/org/apache/torque/adapter DBFactory.java
               src/java/org/apache/torque/oid IDBroker.java
  Log:
  * make Torque implement Configurable and Initializeable
  * use the stratum.configuration package instead of ExtendedProperties
  
  Revision  Changes    Path
  1.43      +121 -39   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.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Torque.java	8 Jan 2002 20:50:07 -0000	1.42
  +++ Torque.java	6 Feb 2002 15:18:56 -0000	1.43
  @@ -3,7 +3,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -63,7 +63,6 @@
   import java.util.List;
   import java.util.Vector;
   import java.util.Properties;
  -import org.apache.commons.collections.ExtendedProperties;
   import org.apache.log4j.Category;
   import org.apache.log4j.PropertyConfigurator;
   import org.apache.log4j.helpers.NullEnumeration;
  @@ -76,6 +75,11 @@
   import org.apache.torque.pool.ConnectionPool;
   import org.apache.torque.pool.DBConnection;
   import org.apache.torque.util.BasePeer;
  +import org.apache.stratum.configuration.Configuration;
  +import org.apache.stratum.configuration.PropertiesConfiguration;
  +import org.apache.stratum.exception.NestableException;
  +import org.apache.stratum.lifecycle.Configurable;
  +import org.apache.stratum.lifecycle.Initializable;
   
   /**
    * The implementation of Torque.
  @@ -84,9 +88,10 @@
    * @author <a href="mailto:magnus@handtolvur.is">Magn�s ��r Torfason</a>
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
  - * @version $Id: Torque.java,v 1.42 2002/01/08 20:50:07 dlr Exp $
  + * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
  + * @version $Id: Torque.java,v 1.43 2002/02/06 15:18:56 mpoeschl Exp $
    */
  -public class Torque
  +public class Torque implements Initializable, Configurable
   {
       /**
        * Name of property that specifies the default
  @@ -104,8 +109,8 @@
        */
       private static String defaultDBName;
   
  -    /** 
  -     * The global cache of database maps 
  +    /**
  +     * The global cache of database maps
        */
       private static Map dbMaps;
   
  @@ -118,13 +123,13 @@
       /**
        * The logging category.
        */
  -    private static Category category = 
  +    private static Category category =
           Category.getInstance(Torque.class.getName());
   
       /**
        * Torque-specific configuration.
        */
  -    private static ExtendedProperties configuration;
  +    private static Configuration configuration;
   
       /**
        * The connection pool monitor.
  @@ -144,6 +149,83 @@
        */
       private static List mapBuilders = new Vector();
   
  +
  +    /**
  +     * initialize Torque
  +     *
  +     * @see org.apache.stratum.lifecycle.Initializable
  +     */
  +    public void initialize() throws Exception
  +    {
  +        // FIX ME!!
  +        // duplicated code init(Configuration)
  +        if (configuration == null)
  +        {
  +            throw new Exception("Torque cannot be initialized without " +
  +                "a valid configuration. Please check the log files " +
  +                    "for further details.");
  +        }
  +
  +        // Setup log4j, I suppose we might want to deal with
  +        // systems other than log4j ...
  +        configureLogging();
  +
  +        // Now that we have dealt with processing the log4j properties
  +        // that may be contained in the configuration we will make the
  +        // configuration consist only of the remain torque specific
  +        // properties that are contained in the configuration. First
  +        // look for properties that are in the "torque" namespace.
  +        Configuration originalConf = configuration;
  +        configuration = configuration.subset("torque");
  +
  +        if (configuration == null || configuration.isEmpty())
  +        {
  +            // If there are no properties in the "torque" namespace
  +            // than try the "services.DatabaseService" namespace. This
  +            // will soon be deprecated.
  +            configuration = originalConf.subset("services.DatabaseService");
  +
  +            // the configuration may already have any prefixes stripped
  +            if (configuration == null || configuration.isEmpty())
  +            {
  +                configuration = originalConf;
  +            }
  +        }
  +
  +        dbMaps = new HashMap();
  +        pools = new HashMap();
  +        DBFactory.init(configuration);
  +
  +        isInit = true;
  +        for (Iterator i = mapBuilders.iterator(); i.hasNext(); )
  +        {
  +            //this will add any maps in this builder to the proper database map
  +            BasePeer.getMapBuilder((String)i.next());
  +        }
  +        // any further mapBuilders will be called/built on demand
  +        mapBuilders = null;
  +
  +
  +        // Create monitor thread
  +        monitor = new Monitor();
  +        // Indicate that this is a system thread. JVM will quit only when there
  +        // are no more active user threads. Settings threads spawned internally
  +        // by Turbine as daemons allows commandline applications using Turbine
  +        // to terminate in an orderly manner.
  +        monitor.setDaemon(true);
  +        monitor.start();
  +    }
  +
  +    /**
  +     * configure torque
  +     *
  +     * @see org.apache.stratum.lifecycle.Configurable
  +     */
  +    public void configure(Configuration config) throws NestableException
  +    {
  +        configuration = config;
  +    }
  +
       /**
        * Initialization of Torque with a properties file.
        *
  @@ -152,7 +234,7 @@
       public static void init(String configFile)
           throws Exception
       {
  -        ExtendedProperties c = new ExtendedProperties(configFile);
  +        Configuration c = (Configuration)new PropertiesConfiguration(configFile);
           init(c);
       }
   
  @@ -161,7 +243,7 @@
        *
        * @param c The Torque configuration.
        */
  -    public static void init(ExtendedProperties c)
  +    public static void init(Configuration c)
           throws Exception
       {
           Torque.setConfiguration(c);
  @@ -170,20 +252,20 @@
               throw new Exception("Torque cannot be initialized without " +
                   "a valid configuration. Please check the log files " +
                       "for further details.");
  -        }            
  -        
  +        }
  +
           // Setup log4j, I suppose we might want to deal with
           // systems other than log4j ...
           configureLogging();
  -        
  +
           // Now that we have dealt with processing the log4j properties
           // that may be contained in the configuration we will make the
           // configuration consist only of the remain torque specific
  -        // properties that are contained in the configuration. First 
  +        // properties that are contained in the configuration. First
           // look for properties that are in the "torque" namespace.
  -        ExtendedProperties originalConf = configuration;
  +        Configuration originalConf = configuration;
           configuration = configuration.subset("torque");
  -        
  +
           if (configuration == null || configuration.isEmpty())
           {
               // If there are no properties in the "torque" namespace
  @@ -195,7 +277,7 @@
               if (configuration == null || configuration.isEmpty())
               {
                   configuration = originalConf;
  -            }            
  +            }
           }
   
           dbMaps = new HashMap();
  @@ -203,14 +285,14 @@
           DBFactory.init(configuration);
   
           isInit = true;
  -        for ( Iterator i=mapBuilders.iterator(); i.hasNext(); ) 
  +        for (Iterator i = mapBuilders.iterator(); i.hasNext(); )
           {
               //this will add any maps in this builder to the proper database map
               BasePeer.getMapBuilder((String)i.next());
           }
           // any further mapBuilders will be called/built on demand
           mapBuilders = null;
  -        
  +
   
           // Create monitor thread
           monitor = new Monitor();
  @@ -230,7 +312,7 @@
       /**
        * Sets the configuration for Torque and all dependencies.
        */
  -    public static void setConfiguration(ExtendedProperties c)
  +    public static void setConfiguration(Configuration c)
       {
           configuration = c;
       }
  @@ -238,11 +320,11 @@
       /**
        * Get the configuration for this component.
        */
  -    public static ExtendedProperties getConfiguration()
  +    public static Configuration getConfiguration()
       {
           return configuration;
  -    }        
  -    
  +    }
  +
       /**
        * Configure the logging for this subsystem.
        */
  @@ -252,9 +334,9 @@
           {
               // Get the applicationRoot for use in the log4j
               // properties.
  -            String applicationRoot = 
  +            String applicationRoot =
                   getConfiguration().getString("torque.applicationRoot", ".");
  -            
  +
               //!! Need a configurable log directory.
               File logsDir = new File(applicationRoot, "logs");
   
  @@ -267,29 +349,29 @@
               }
   
               // Extract the log4j values out of the configuration and
  -            // place them in a Properties object so that we can 
  +            // place them in a Properties object so that we can
               // use the log4j PropertyConfigurator.
               Properties p = new Properties();
               p.put("torque.applicationRoot", applicationRoot);
  -            
  +
               Iterator i = getConfiguration().getKeys();
               while (i.hasNext())
               {
                   String key = (String) i.next();
  -                
  +
                   // We only want log4j properties.
                   if (key.startsWith("log4j") == false)
                   {
                       continue;
                   }
  -                
  +
                   // We have to deal with ExtendedProperties way
                   // of dealing with "," in properties which is to
                   // make them separate values. Log4j category
                   // properties contain commas so we must stick them
                   // back together for log4j.
                   String[] values = getConfiguration().getStringArray(key);
  -                
  +
                   String value;
                   if (values.length == 1)
                   {
  @@ -298,15 +380,15 @@
                   else
                   {
                       value = values[0] + "," + values[1];
  -                }                    
  -                
  +                }
  +
                   p.put(key, value);
  -            } 
  -            
  +            }
  +
               PropertyConfigurator.configure(p);
               category.info("Logging has been configured by Torque.");
           }
  -        
  +
       }
   
       /**
  @@ -482,7 +564,7 @@
       public static void registerMapBuilder(String className)
       {
           mapBuilders.add(className);
  -    } 
  +    }
   
       /**
        * Returns the specified property of the given database, or the empty
  @@ -835,7 +917,7 @@
                           .append(pool.getNbrAvailable()).append(" + ")
                           .append(pool.getNbrCheckedOut()).append(" = ")
                           .append(pool.getTotalCount());
  -                    
  +
                       category.info(buf.toString());
                   }
   
  @@ -865,10 +947,10 @@
           // same object.
           else if (defaultDBName == null)
           {
  -            defaultDBName = 
  +            defaultDBName =
                   configuration.getString(DATABASE_DEFAULT, DEFAULT_NAME);
           }
  -        
  +
           return defaultDBName;
       }
   
  
  
  
  1.20      +4 -3      jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBFactory.java
  
  Index: DBFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBFactory.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DBFactory.java	14 Dec 2001 22:14:06 -0000	1.19
  +++ DBFactory.java	6 Feb 2002 15:18:56 -0000	1.20
  @@ -56,8 +56,9 @@
   
   import java.util.Hashtable;
   import java.util.Iterator;
  -import org.apache.commons.collections.ExtendedProperties;
   import org.apache.log4j.Category;
  +import org.apache.stratum.configuration.Configuration;
  +
   
   /**
    * This class creates different {@link org.apache.torque.adapter.DB}
  @@ -68,7 +69,7 @@
    * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
    * @author <a href="mailto:ralf@reswi.ruhr.de">Ralf Stranzenbach</a>
    * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
  - * @version $Id: DBFactory.java,v 1.19 2001/12/14 22:14:06 brekke Exp $
  + * @version $Id: DBFactory.java,v 1.20 2002/02/06 15:18:56 mpoeschl Exp $
    */
   public class DBFactory
   {
  @@ -101,7 +102,7 @@
        * configuration is queried to get a list of JDBC drivers and
        * their associated adapters.
        */
  -    public static void init(ExtendedProperties configuration)
  +    public static void init(Configuration configuration)
       {
           adapters = new Hashtable();
           initializeDriverToAdapterMap();
  
  
  
  1.11      +5 -5      jakarta-turbine-torque/src/java/org/apache/torque/oid/IDBroker.java
  
  Index: IDBroker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/oid/IDBroker.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- IDBroker.java	26 Nov 2001 23:46:16 -0000	1.10
  +++ IDBroker.java	6 Feb 2002 15:18:56 -0000	1.11
  @@ -64,8 +64,8 @@
   import java.util.Enumeration;
   import java.util.Hashtable;
   import java.util.List;
  -import org.apache.commons.collections.ExtendedProperties;
   import org.apache.log4j.Category;
  +import org.apache.stratum.configuration.Configuration;
   import org.apache.torque.Torque;
   import org.apache.torque.TorqueException;
   import org.apache.torque.map.DatabaseMap;
  @@ -113,7 +113,7 @@
    *
    * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
  - * @version $Id: IDBroker.java,v 1.10 2001/11/26 23:46:16 jmcnally Exp $
  + * @version $Id: IDBroker.java,v 1.11 2002/02/06 15:18:56 mpoeschl Exp $
    */
   public class IDBroker
       implements Runnable, IdGenerator
  @@ -196,7 +196,7 @@
        */
       private static final BigDecimal ONE = new BigDecimal("1");
   
  -    private ExtendedProperties configuration;
  +    private Configuration configuration;
   
       private static final String DB_IDBROKER_CLEVERQUANTITY =
           "idbroker.clever.quantity";
  @@ -219,7 +219,7 @@
       {
           this.tableMap = tMap;
           configuration = Torque.getConfiguration();
  -        
  +
           // Start the housekeeper thread only if prefetch has not been disabled
           if (configuration.getBoolean(DB_IDBROKER_PREFETCH, true))
           {
  @@ -270,7 +270,7 @@
           }
       }
   
  -    public void setConfiguration(ExtendedProperties configuration)
  +    public void setConfiguration(Configuration configuration)
       {
           this.configuration = configuration;
       }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Martin Poeschl <mp...@marmot.at>.
Pete Kazmier wrote:
> One more, stratum's deps.list is missing commons-collections.jar.  Patch
> included for humor :)

:) done

thanx!

martin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Pete Kazmier <pe...@kazmier.com>.
One more, stratum's deps.list is missing commons-collections.jar.  Patch
included for humor :)

Thanks!
Pete

On Thu, Feb 07, 2002 at 03:30:53PM +0100, Martin Poeschl wrote:
> Pete Kazmier wrote:
> > This broke the Torque build because deps.list doesn't include the
> > stratum jar.  Build.xml also needs to be modified as well (checks for
> > properties and packaging of stratum.jar in the zip distribution).  I've
> > included a patch for build.xml and deps.list that resolves these issues.
> 
> done

Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Martin Poeschl <mp...@marmot.at>.
Pete Kazmier wrote:
> This broke the Torque build because deps.list doesn't include the
> stratum jar.  Build.xml also needs to be modified as well (checks for
> properties and packaging of stratum.jar in the zip distribution).  I've
> included a patch for build.xml and deps.list that resolves these issues.

done

> 
> Additionally, someone will also need to update the stratum jar at
> http://jakarta.apache.org/turbine/jars because it will not build Torque
> as it stands.

done

thanx!

martin

> 
> Thanks!
> Pete
> 
> On Wed, Feb 06, 2002 at 03:18:56PM -0000, mpoeschl@apache.org wrote:
> 
>>mpoeschl    02/02/06 07:18:56
>>
>>  Modified:    src/java/org/apache/torque Torque.java
>>               src/java/org/apache/torque/adapter DBFactory.java
>>               src/java/org/apache/torque/oid IDBroker.java
>>  Log:
>>  * make Torque implement Configurable and Initializeable
>>  * use the stratum.configuration package instead of ExtendedProperties
>>  


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Pete Kazmier <pe...@kazmier.com>.
This broke the Torque build because deps.list doesn't include the
stratum jar.  Build.xml also needs to be modified as well (checks for
properties and packaging of stratum.jar in the zip distribution).  I've
included a patch for build.xml and deps.list that resolves these issues.

Additionally, someone will also need to update the stratum jar at
http://jakarta.apache.org/turbine/jars because it will not build Torque
as it stands.

Thanks!
Pete

On Wed, Feb 06, 2002 at 03:18:56PM -0000, mpoeschl@apache.org wrote:
> mpoeschl    02/02/06 07:18:56
> 
>   Modified:    src/java/org/apache/torque Torque.java
>                src/java/org/apache/torque/adapter DBFactory.java
>                src/java/org/apache/torque/oid IDBroker.java
>   Log:
>   * make Torque implement Configurable and Initializeable
>   * use the stratum.configuration package instead of ExtendedProperties
>   
>   Revision  Changes    Path
>   1.43      +121 -39   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.42
>   retrieving revision 1.43
>   diff -u -r1.42 -r1.43
>   --- Torque.java	8 Jan 2002 20:50:07 -0000	1.42
>   +++ Torque.java	6 Feb 2002 15:18:56 -0000	1.43
>   @@ -3,7 +3,7 @@
>    /* ====================================================================
>     * The Apache Software License, Version 1.1
>     *
>   - * Copyright (c) 2001 The Apache Software Foundation.  All rights
>   + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
>     * reserved.
>     *
>     * Redistribution and use in source and binary forms, with or without
>   @@ -63,7 +63,6 @@
>    import java.util.List;
>    import java.util.Vector;
>    import java.util.Properties;
>   -import org.apache.commons.collections.ExtendedProperties;
>    import org.apache.log4j.Category;
>    import org.apache.log4j.PropertyConfigurator;
>    import org.apache.log4j.helpers.NullEnumeration;
>   @@ -76,6 +75,11 @@
>    import org.apache.torque.pool.ConnectionPool;
>    import org.apache.torque.pool.DBConnection;
>    import org.apache.torque.util.BasePeer;
>   +import org.apache.stratum.configuration.Configuration;
>   +import org.apache.stratum.configuration.PropertiesConfiguration;
>   +import org.apache.stratum.exception.NestableException;
>   +import org.apache.stratum.lifecycle.Configurable;
>   +import org.apache.stratum.lifecycle.Initializable;
>    
>    /**
>     * The implementation of Torque.
>   @@ -84,9 +88,10 @@
>     * @author <a href="mailto:magnus@handtolvur.is">Magnús Þór Torfason</a>
>     * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
>     * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
>   - * @version $Id: Torque.java,v 1.42 2002/01/08 20:50:07 dlr Exp $
>   + * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
>   + * @version $Id: Torque.java,v 1.43 2002/02/06 15:18:56 mpoeschl Exp $
>     */
>   -public class Torque
>   +public class Torque implements Initializable, Configurable
>    {
>        /**
>         * Name of property that specifies the default
>   @@ -104,8 +109,8 @@
>         */
>        private static String defaultDBName;
>    
>   -    /** 
>   -     * The global cache of database maps 
>   +    /**
>   +     * The global cache of database maps
>         */
>        private static Map dbMaps;
>    
>   @@ -118,13 +123,13 @@
>        /**
>         * The logging category.
>         */
>   -    private static Category category = 
>   +    private static Category category =
>            Category.getInstance(Torque.class.getName());
>    
>        /**
>         * Torque-specific configuration.
>         */
>   -    private static ExtendedProperties configuration;
>   +    private static Configuration configuration;
>    
>        /**
>         * The connection pool monitor.
>   @@ -144,6 +149,83 @@
>         */
>        private static List mapBuilders = new Vector();
>    
>   +
>   +    /**
>   +     * initialize Torque
>   +     *
>   +     * @see org.apache.stratum.lifecycle.Initializable
>   +     */
>   +    public void initialize() throws Exception
>   +    {
>   +        // FIX ME!!
>   +        // duplicated code init(Configuration)
>   +        if (configuration == null)
>   +        {
>   +            throw new Exception("Torque cannot be initialized without " +
>   +                "a valid configuration. Please check the log files " +
>   +                    "for further details.");
>   +        }
>   +
>   +        // Setup log4j, I suppose we might want to deal with
>   +        // systems other than log4j ...
>   +        configureLogging();
>   +
>   +        // Now that we have dealt with processing the log4j properties
>   +        // that may be contained in the configuration we will make the
>   +        // configuration consist only of the remain torque specific
>   +        // properties that are contained in the configuration. First
>   +        // look for properties that are in the "torque" namespace.
>   +        Configuration originalConf = configuration;
>   +        configuration = configuration.subset("torque");
>   +
>   +        if (configuration == null || configuration.isEmpty())
>   +        {
>   +            // If there are no properties in the "torque" namespace
>   +            // than try the "services.DatabaseService" namespace. This
>   +            // will soon be deprecated.
>   +            configuration = originalConf.subset("services.DatabaseService");
>   +
>   +            // the configuration may already have any prefixes stripped
>   +            if (configuration == null || configuration.isEmpty())
>   +            {
>   +                configuration = originalConf;
>   +            }
>   +        }
>   +
>   +        dbMaps = new HashMap();
>   +        pools = new HashMap();
>   +        DBFactory.init(configuration);
>   +
>   +        isInit = true;
>   +        for (Iterator i = mapBuilders.iterator(); i.hasNext(); )
>   +        {
>   +            //this will add any maps in this builder to the proper database map
>   +            BasePeer.getMapBuilder((String)i.next());
>   +        }
>   +        // any further mapBuilders will be called/built on demand
>   +        mapBuilders = null;
>   +
>   +
>   +        // Create monitor thread
>   +        monitor = new Monitor();
>   +        // Indicate that this is a system thread. JVM will quit only when there
>   +        // are no more active user threads. Settings threads spawned internally
>   +        // by Turbine as daemons allows commandline applications using Turbine
>   +        // to terminate in an orderly manner.
>   +        monitor.setDaemon(true);
>   +        monitor.start();
>   +    }
>   +
>   +    /**
>   +     * configure torque
>   +     *
>   +     * @see org.apache.stratum.lifecycle.Configurable
>   +     */
>   +    public void configure(Configuration config) throws NestableException
>   +    {
>   +        configuration = config;
>   +    }
>   +
>        /**
>         * Initialization of Torque with a properties file.
>         *
>   @@ -152,7 +234,7 @@
>        public static void init(String configFile)
>            throws Exception
>        {
>   -        ExtendedProperties c = new ExtendedProperties(configFile);
>   +        Configuration c = (Configuration)new PropertiesConfiguration(configFile);
>            init(c);
>        }
>    
>   @@ -161,7 +243,7 @@
>         *
>         * @param c The Torque configuration.
>         */
>   -    public static void init(ExtendedProperties c)
>   +    public static void init(Configuration c)
>            throws Exception
>        {
>            Torque.setConfiguration(c);
>   @@ -170,20 +252,20 @@
>                throw new Exception("Torque cannot be initialized without " +
>                    "a valid configuration. Please check the log files " +
>                        "for further details.");
>   -        }            
>   -        
>   +        }
>   +
>            // Setup log4j, I suppose we might want to deal with
>            // systems other than log4j ...
>            configureLogging();
>   -        
>   +
>            // Now that we have dealt with processing the log4j properties
>            // that may be contained in the configuration we will make the
>            // configuration consist only of the remain torque specific
>   -        // properties that are contained in the configuration. First 
>   +        // properties that are contained in the configuration. First
>            // look for properties that are in the "torque" namespace.
>   -        ExtendedProperties originalConf = configuration;
>   +        Configuration originalConf = configuration;
>            configuration = configuration.subset("torque");
>   -        
>   +
>            if (configuration == null || configuration.isEmpty())
>            {
>                // If there are no properties in the "torque" namespace
>   @@ -195,7 +277,7 @@
>                if (configuration == null || configuration.isEmpty())
>                {
>                    configuration = originalConf;
>   -            }            
>   +            }
>            }
>    
>            dbMaps = new HashMap();
>   @@ -203,14 +285,14 @@
>            DBFactory.init(configuration);
>    
>            isInit = true;
>   -        for ( Iterator i=mapBuilders.iterator(); i.hasNext(); ) 
>   +        for (Iterator i = mapBuilders.iterator(); i.hasNext(); )
>            {
>                //this will add any maps in this builder to the proper database map
>                BasePeer.getMapBuilder((String)i.next());
>            }
>            // any further mapBuilders will be called/built on demand
>            mapBuilders = null;
>   -        
>   +
>    
>            // Create monitor thread
>            monitor = new Monitor();
>   @@ -230,7 +312,7 @@
>        /**
>         * Sets the configuration for Torque and all dependencies.
>         */
>   -    public static void setConfiguration(ExtendedProperties c)
>   +    public static void setConfiguration(Configuration c)
>        {
>            configuration = c;
>        }
>   @@ -238,11 +320,11 @@
>        /**
>         * Get the configuration for this component.
>         */
>   -    public static ExtendedProperties getConfiguration()
>   +    public static Configuration getConfiguration()
>        {
>            return configuration;
>   -    }        
>   -    
>   +    }
>   +
>        /**
>         * Configure the logging for this subsystem.
>         */
>   @@ -252,9 +334,9 @@
>            {
>                // Get the applicationRoot for use in the log4j
>                // properties.
>   -            String applicationRoot = 
>   +            String applicationRoot =
>                    getConfiguration().getString("torque.applicationRoot", ".");
>   -            
>   +
>                //!! Need a configurable log directory.
>                File logsDir = new File(applicationRoot, "logs");
>    
>   @@ -267,29 +349,29 @@
>                }
>    
>                // Extract the log4j values out of the configuration and
>   -            // place them in a Properties object so that we can 
>   +            // place them in a Properties object so that we can
>                // use the log4j PropertyConfigurator.
>                Properties p = new Properties();
>                p.put("torque.applicationRoot", applicationRoot);
>   -            
>   +
>                Iterator i = getConfiguration().getKeys();
>                while (i.hasNext())
>                {
>                    String key = (String) i.next();
>   -                
>   +
>                    // We only want log4j properties.
>                    if (key.startsWith("log4j") == false)
>                    {
>                        continue;
>                    }
>   -                
>   +
>                    // We have to deal with ExtendedProperties way
>                    // of dealing with "," in properties which is to
>                    // make them separate values. Log4j category
>                    // properties contain commas so we must stick them
>                    // back together for log4j.
>                    String[] values = getConfiguration().getStringArray(key);
>   -                
>   +
>                    String value;
>                    if (values.length == 1)
>                    {
>   @@ -298,15 +380,15 @@
>                    else
>                    {
>                        value = values[0] + "," + values[1];
>   -                }                    
>   -                
>   +                }
>   +
>                    p.put(key, value);
>   -            } 
>   -            
>   +            }
>   +
>                PropertyConfigurator.configure(p);
>                category.info("Logging has been configured by Torque.");
>            }
>   -        
>   +
>        }
>    
>        /**
>   @@ -482,7 +564,7 @@
>        public static void registerMapBuilder(String className)
>        {
>            mapBuilders.add(className);
>   -    } 
>   +    }
>    
>        /**
>         * Returns the specified property of the given database, or the empty
>   @@ -835,7 +917,7 @@
>                            .append(pool.getNbrAvailable()).append(" + ")
>                            .append(pool.getNbrCheckedOut()).append(" = ")
>                            .append(pool.getTotalCount());
>   -                    
>   +
>                        category.info(buf.toString());
>                    }
>    
>   @@ -865,10 +947,10 @@
>            // same object.
>            else if (defaultDBName == null)
>            {
>   -            defaultDBName = 
>   +            defaultDBName =
>                    configuration.getString(DATABASE_DEFAULT, DEFAULT_NAME);
>            }
>   -        
>   +
>            return defaultDBName;
>        }
>    
>   
>   
>   
>   1.20      +4 -3      jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBFactory.java
>   
>   Index: DBFactory.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBFactory.java,v
>   retrieving revision 1.19
>   retrieving revision 1.20
>   diff -u -r1.19 -r1.20
>   --- DBFactory.java	14 Dec 2001 22:14:06 -0000	1.19
>   +++ DBFactory.java	6 Feb 2002 15:18:56 -0000	1.20
>   @@ -56,8 +56,9 @@
>    
>    import java.util.Hashtable;
>    import java.util.Iterator;
>   -import org.apache.commons.collections.ExtendedProperties;
>    import org.apache.log4j.Category;
>   +import org.apache.stratum.configuration.Configuration;
>   +
>    
>    /**
>     * This class creates different {@link org.apache.torque.adapter.DB}
>   @@ -68,7 +69,7 @@
>     * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
>     * @author <a href="mailto:ralf@reswi.ruhr.de">Ralf Stranzenbach</a>
>     * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
>   - * @version $Id: DBFactory.java,v 1.19 2001/12/14 22:14:06 brekke Exp $
>   + * @version $Id: DBFactory.java,v 1.20 2002/02/06 15:18:56 mpoeschl Exp $
>     */
>    public class DBFactory
>    {
>   @@ -101,7 +102,7 @@
>         * configuration is queried to get a list of JDBC drivers and
>         * their associated adapters.
>         */
>   -    public static void init(ExtendedProperties configuration)
>   +    public static void init(Configuration configuration)
>        {
>            adapters = new Hashtable();
>            initializeDriverToAdapterMap();
>   
>   
>   
>   1.11      +5 -5      jakarta-turbine-torque/src/java/org/apache/torque/oid/IDBroker.java
>   
>   Index: IDBroker.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/oid/IDBroker.java,v
>   retrieving revision 1.10
>   retrieving revision 1.11
>   diff -u -r1.10 -r1.11
>   --- IDBroker.java	26 Nov 2001 23:46:16 -0000	1.10
>   +++ IDBroker.java	6 Feb 2002 15:18:56 -0000	1.11
>   @@ -64,8 +64,8 @@
>    import java.util.Enumeration;
>    import java.util.Hashtable;
>    import java.util.List;
>   -import org.apache.commons.collections.ExtendedProperties;
>    import org.apache.log4j.Category;
>   +import org.apache.stratum.configuration.Configuration;
>    import org.apache.torque.Torque;
>    import org.apache.torque.TorqueException;
>    import org.apache.torque.map.DatabaseMap;
>   @@ -113,7 +113,7 @@
>     *
>     * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
>     * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
>   - * @version $Id: IDBroker.java,v 1.10 2001/11/26 23:46:16 jmcnally Exp $
>   + * @version $Id: IDBroker.java,v 1.11 2002/02/06 15:18:56 mpoeschl Exp $
>     */
>    public class IDBroker
>        implements Runnable, IdGenerator
>   @@ -196,7 +196,7 @@
>         */
>        private static final BigDecimal ONE = new BigDecimal("1");
>    
>   -    private ExtendedProperties configuration;
>   +    private Configuration configuration;
>    
>        private static final String DB_IDBROKER_CLEVERQUANTITY =
>            "idbroker.clever.quantity";
>   @@ -219,7 +219,7 @@
>        {
>            this.tableMap = tMap;
>            configuration = Torque.getConfiguration();
>   -        
>   +
>            // Start the housekeeper thread only if prefetch has not been disabled
>            if (configuration.getBoolean(DB_IDBROKER_PREFETCH, true))
>            {
>   @@ -270,7 +270,7 @@
>            }
>        }
>    
>   -    public void setConfiguration(ExtendedProperties configuration)
>   +    public void setConfiguration(Configuration configuration)
>        {
>            this.configuration = configuration;
>        }
>   
>   
>   
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Peter Kazmier                                 http://www.kazmier.com
PGP Fingerprint   4FE7 8DA3 D0B5 9CAA 69DC  7243 1855 BC2E 4B43 5654

Re: cvs commit:jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Kelvin Tan <ke...@relevanz.com>.
Ok. Makes a good deal of sense. Just wasn't clear if it was duplication of effort, but if the eventual goal is to move it to Commons, don't see why not.

May be able to contribute the XML one, but have to take a look at the Configuration first.

Kelvin
  ----- Original Message ----- 
  From: James Taylor 
  To: Turbine Developers List 
  Sent: Thursday, February 07, 2002 8:15 PM
  Subject: Re: cvs commit:jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java


  The configuration package contains an interface for accessing config
  data. One implementation of Configuration is properties based, which is
  similar to / based on ExtendedProperties. However using the
  configuration package allows use of other (yet to be implemented)
  configuration formats. An XML one is planned (the empty class is already
  there). In the future others will exist, or users can implement their
  own, and configure fulcrum, torque, or turbine with it.

  The move is turbine level only. This is consistent with the goals of
  stratum, to isolate reusable discrete components in turbine, factor them
  out, refine them, and when they are ready eventually move them to
  commons.

  More abstraction, more flexibility.

  -- jt

  On Thu, 2002-02-07 at 04:17, Kelvin Tan wrote:
  > I see. Hmmm...so if you don't mind me asking, what's the purpose behind this migration? Didn't see much discussion on the mailing list about this...(or I might've missed it in the noise)
  > 
  > Is it an Apache-level move towards stratum.configuration, or is the purpose for the Turbine project to be more self-contained? And of course, the reply begs the question: if it's more or less the same, why move? :)
  > 
  > Haven't seen the stratum.configuration package (think it was introduced yesterday or the day before only), but is it a wrapper around ExtendedProps or an implementation as well?
  > 
  > K
  >   ----- Original Message ----- 
  >   From: Martin Poeschl 
  >   To: Turbine Developers List 
  >   Sent: Thursday, February 07, 2002 4:47 PM
  >   Subject: Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java
  > 
  > 
  >   Kelvin Tan wrote:
  >   > I've noticed a bunch of commits moving away from Commons' ExtendedProperties, towards stratum.configuration. 
  >   > 
  >   > How stable is stratum.configuration wrt to ExtendedProperties? Would you consider it production-quality?
  > 
  >   the code for the configuration package is more or less the same as ExtendedProperties
  > 
  >   > 
  >   > Regards,
  >   > Kelvin
  > 
  > 
  > 
  > 
  >   --
  >   To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
  >   For additional commands, e-mail: <ma...@jakarta.apache.org>
  > 
  > 



  --
  To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
  For additional commands, e-mail: <ma...@jakarta.apache.org>



Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Jason van Zyl <jv...@zenplex.com>.
On 2/8/02 8:03 AM, "James Taylor" <jt...@4lane.com> wrote:

>>> +1.  The .properties-style Configuration implementation should
>>> subclass ExtendedProperties.
>> 
>> No, I don't think this is right. A lot of the code was borrowed from the
>> ExtendedProperties and the core can be used in the BaseConfiguration but the
>> I/O should be removed from the ExtendedProperties and the resources package
>> should be removed. I would also like to fix some problems that are in the
>> ExtendedProperties.
> 
> It seems to me that it would be nice to push some functionality up from
> ExtendedProperties. It would be nice if there were a 'MultiValueMap'
> class that handled all of the get / set stuff which
> PropertyConfiguration and ExtendedProperties could both use. Multiple
> value maps are a pretty useful reusable collection, I've ended up
> ripping those parts out of ExtendedProperties more than once when I
> needed such a collection.

All the multi-value code can be pushed into the BaseConfiguration and then
that can be further refactored and a utility can be placed in the commons
util package. That's a good idea. This is what stratum is for: to help us
decouple the turbine code and make it reusable by going back to the commons.

I realize the ExtendedProperties is already in the commons but it was more
of a stop gap solution (IMO) so that Velocity and Turbine could share this
class and to show that we too want to share out utility code (which we have
subsequently shown by moving our utility code to the commons) but I think
further work needs to be done. I would like to return the configuration
package back to the commons spiffed up so that more people can use it.

 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by James Taylor <jt...@4lane.com>.
> > +1.  The .properties-style Configuration implementation should
> > subclass ExtendedProperties.
> 
> No, I don't think this is right. A lot of the code was borrowed from the
> ExtendedProperties and the core can be used in the BaseConfiguration but the
> I/O should be removed from the ExtendedProperties and the resources package
> should be removed. I would also like to fix some problems that are in the
> ExtendedProperties.

It seems to me that it would be nice to push some functionality up from
ExtendedProperties. It would be nice if there were a 'MultiValueMap'
class that handled all of the get / set stuff which
PropertyConfiguration and ExtendedProperties could both use. Multiple
value maps are a pretty useful reusable collection, I've ended up
ripping those parts out of ExtendedProperties more than once when I
needed such a collection.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Jason van Zyl <jv...@zenplex.com>.
On 2/8/02 8:02 AM, "Jason van Zyl" <jv...@zenplex.com> wrote:

> On 2/7/02 10:17 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
> 
>> James Taylor <jt...@4lane.com> writes:
>> 
>>> The configuration package contains an interface for accessing config
>>> data. One implementation of Configuration is properties based, which is
>>> similar to / based on ExtendedProperties. However using the
>>> configuration package allows use of other (yet to be implemented)
>>> configuration formats. An XML one is planned (the empty class is already
>>> there). In the future others will exist, or users can implement their
>>> own, and configure fulcrum, torque, or turbine with it.
>> 
>> +1.  The .properties-style Configuration implementation should
>> subclass ExtendedProperties.
> 
> No, I don't think this is right. A lot of the code was borrowed from the
> ExtendedProperties and the core can be used in the BaseConfiguration but the
> I/O should be removed from the ExtendedProperties and the resources package
> should be removed.

Sorry, that's the "resource package should be used". Not enough coffee in
the bloodstream yet.

> I would also like to fix some problems that are in the
> ExtendedProperties.
> 
> The current user list of the ExtendedProperties is more then likely Turbine
> and Velocity. I believe the reworked configuration that uses the resources
> package will be a much better solution.
> 
>> --
>> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Jason van Zyl <jv...@zenplex.com>.
On 2/7/02 10:17 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:

> James Taylor <jt...@4lane.com> writes:
> 
>> The configuration package contains an interface for accessing config
>> data. One implementation of Configuration is properties based, which is
>> similar to / based on ExtendedProperties. However using the
>> configuration package allows use of other (yet to be implemented)
>> configuration formats. An XML one is planned (the empty class is already
>> there). In the future others will exist, or users can implement their
>> own, and configure fulcrum, torque, or turbine with it.
> 
> +1.  The .properties-style Configuration implementation should
> subclass ExtendedProperties.

No, I don't think this is right. A lot of the code was borrowed from the
ExtendedProperties and the core can be used in the BaseConfiguration but the
I/O should be removed from the ExtendedProperties and the resources package
should be removed. I would also like to fix some problems that are in the
ExtendedProperties.

The current user list of the ExtendedProperties is more then likely Turbine
and Velocity. I believe the reworked configuration that uses the resources
package will be a much better solution.

> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Martin Poeschl <mp...@marmot.at>.
Daniel Rall wrote:
> James Taylor <jt...@4lane.com> writes:
> 
> 
>>The configuration package contains an interface for accessing config
>>data. One implementation of Configuration is properties based, which is
>>similar to / based on ExtendedProperties. However using the
>>configuration package allows use of other (yet to be implemented)
>>configuration formats. An XML one is planned (the empty class is already
>>there). In the future others will exist, or users can implement their
>>own, and configure fulcrum, torque, or turbine with it.
>>
> 
> +1.  The .properties-style Configuration implementation should
> subclass ExtendedProperties.

why???
i think the configuration package should (and hopefully will) replace ExtendedProperties

martin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: stratum.configuration and ExtendedProperties [WAS Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java]

Posted by Jason van Zyl <jv...@zenplex.com>.
On 2/7/02 10:48 PM, "Kelvin Tan" <ke...@relevanz.com> wrote:

> 
> 
>> James Taylor <jt...@4lane.com> writes:
>> 
>>> The configuration package contains an interface for accessing config
>>> data. One implementation of Configuration is properties based, which is
>>> similar to / based on ExtendedProperties. However using the
>>> configuration package allows use of other (yet to be implemented)
>>> configuration formats. An XML one is planned (the empty class is already
>>> there). In the future others will exist, or users can implement their
>>> own, and configure fulcrum, torque, or turbine with it.
>> 
>> +1.  The .properties-style Configuration implementation should
>> subclass ExtendedProperties.
>> 
> 
> hmmm. I don't know about that. Currently PropertiesConfiguration already
> subclasses BaseConfiguration. What could be done would be to extract
> ExtendedProperties' method signatures into an interface and have
> PropertiesConfiguration implement that?

I believe the path we're moving down is the right one. The
ExtendedProperties needed some work anyway. It would also be nice to make
the configuration package compatible with the 1.4 Preferences API.


> Kelvin
> 
>> --
>> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>> 
>> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


stratum.configuration and ExtendedProperties [WAS Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java]

Posted by Kelvin Tan <ke...@relevanz.com>.

> James Taylor <jt...@4lane.com> writes:
>
> > The configuration package contains an interface for accessing config
> > data. One implementation of Configuration is properties based, which is
> > similar to / based on ExtendedProperties. However using the
> > configuration package allows use of other (yet to be implemented)
> > configuration formats. An XML one is planned (the empty class is already
> > there). In the future others will exist, or users can implement their
> > own, and configure fulcrum, torque, or turbine with it.
>
> +1.  The .properties-style Configuration implementation should
> subclass ExtendedProperties.
>

hmmm. I don't know about that. Currently PropertiesConfiguration already
subclasses BaseConfiguration. What could be done would be to extract
ExtendedProperties' method signatures into an interface and have
PropertiesConfiguration implement that?

Kelvin

> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Daniel Rall <dl...@finemaltcoding.com>.
James Taylor <jt...@4lane.com> writes:

> The configuration package contains an interface for accessing config
> data. One implementation of Configuration is properties based, which is
> similar to / based on ExtendedProperties. However using the
> configuration package allows use of other (yet to be implemented)
> configuration formats. An XML one is planned (the empty class is already
> there). In the future others will exist, or users can implement their
> own, and configure fulcrum, torque, or turbine with it.

+1.  The .properties-style Configuration implementation should
subclass ExtendedProperties.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by James Taylor <jt...@4lane.com>.
The configuration package contains an interface for accessing config
data. One implementation of Configuration is properties based, which is
similar to / based on ExtendedProperties. However using the
configuration package allows use of other (yet to be implemented)
configuration formats. An XML one is planned (the empty class is already
there). In the future others will exist, or users can implement their
own, and configure fulcrum, torque, or turbine with it.

The move is turbine level only. This is consistent with the goals of
stratum, to isolate reusable discrete components in turbine, factor them
out, refine them, and when they are ready eventually move them to
commons.

More abstraction, more flexibility.

-- jt

On Thu, 2002-02-07 at 04:17, Kelvin Tan wrote:
> I see. Hmmm...so if you don't mind me asking, what's the purpose behind this migration? Didn't see much discussion on the mailing list about this...(or I might've missed it in the noise)
> 
> Is it an Apache-level move towards stratum.configuration, or is the purpose for the Turbine project to be more self-contained? And of course, the reply begs the question: if it's more or less the same, why move? :)
> 
> Haven't seen the stratum.configuration package (think it was introduced yesterday or the day before only), but is it a wrapper around ExtendedProps or an implementation as well?
> 
> K
>   ----- Original Message ----- 
>   From: Martin Poeschl 
>   To: Turbine Developers List 
>   Sent: Thursday, February 07, 2002 4:47 PM
>   Subject: Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java
> 
> 
>   Kelvin Tan wrote:
>   > I've noticed a bunch of commits moving away from Commons' ExtendedProperties, towards stratum.configuration. 
>   > 
>   > How stable is stratum.configuration wrt to ExtendedProperties? Would you consider it production-quality?
> 
>   the code for the configuration package is more or less the same as ExtendedProperties
> 
>   > 
>   > Regards,
>   > Kelvin
> 
> 
> 
> 
>   --
>   To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>   For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Kelvin Tan <ke...@relevanz.com>.
I see. Hmmm...so if you don't mind me asking, what's the purpose behind this migration? Didn't see much discussion on the mailing list about this...(or I might've missed it in the noise)

Is it an Apache-level move towards stratum.configuration, or is the purpose for the Turbine project to be more self-contained? And of course, the reply begs the question: if it's more or less the same, why move? :)

Haven't seen the stratum.configuration package (think it was introduced yesterday or the day before only), but is it a wrapper around ExtendedProps or an implementation as well?

K
  ----- Original Message ----- 
  From: Martin Poeschl 
  To: Turbine Developers List 
  Sent: Thursday, February 07, 2002 4:47 PM
  Subject: Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java


  Kelvin Tan wrote:
  > I've noticed a bunch of commits moving away from Commons' ExtendedProperties, towards stratum.configuration. 
  > 
  > How stable is stratum.configuration wrt to ExtendedProperties? Would you consider it production-quality?

  the code for the configuration package is more or less the same as ExtendedProperties

  > 
  > Regards,
  > Kelvin




  --
  To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
  For additional commands, e-mail: <ma...@jakarta.apache.org>



Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Martin Poeschl <mp...@marmot.at>.
Kelvin Tan wrote:
> I've noticed a bunch of commits moving away from Commons' ExtendedProperties, towards stratum.configuration. 
> 
> How stable is stratum.configuration wrt to ExtendedProperties? Would you consider it production-quality?

the code for the configuration package is more or less the same as ExtendedProperties

> 
> Regards,
> Kelvin




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java

Posted by Kelvin Tan <ke...@relevanz.com>.
I've noticed a bunch of commits moving away from Commons' ExtendedProperties, towards stratum.configuration. 

How stable is stratum.configuration wrt to ExtendedProperties? Would you consider it production-quality?

Regards,
Kelvin
  ----- Original Message ----- 
  From: mpoeschl@apache.org 
  To: jakarta-turbine-torque-cvs@apache.org 
  Sent: Wednesday, February 06, 2002 11:18 PM
  Subject: cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/oid IDBroker.java


  mpoeschl    02/02/06 07:18:56

    Modified:    src/java/org/apache/torque Torque.java
                 src/java/org/apache/torque/adapter DBFactory.java
                 src/java/org/apache/torque/oid IDBroker.java
    Log:
    * make Torque implement Configurable and Initializeable
    * use the stratum.configuration package instead of ExtendedProperties
    
    Revision  Changes    Path
    1.43      +121 -39   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.42
    retrieving revision 1.43
    diff -u -r1.42 -r1.43
    --- Torque.java 8 Jan 2002 20:50:07 -0000 1.42
    +++ Torque.java 6 Feb 2002 15:18:56 -0000 1.43
    @@ -3,7 +3,7 @@
     /* ====================================================================
      * The Apache Software License, Version 1.1
      *
    - * Copyright (c) 2001 The Apache Software Foundation.  All rights
    + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
      * reserved.
      *
      * Redistribution and use in source and binary forms, with or without
    @@ -63,7 +63,6 @@
     import java.util.List;
     import java.util.Vector;
     import java.util.Properties;
    -import org.apache.commons.collections.ExtendedProperties;
     import org.apache.log4j.Category;
     import org.apache.log4j.PropertyConfigurator;
     import org.apache.log4j.helpers.NullEnumeration;
    @@ -76,6 +75,11 @@
     import org.apache.torque.pool.ConnectionPool;
     import org.apache.torque.pool.DBConnection;
     import org.apache.torque.util.BasePeer;
    +import org.apache.stratum.configuration.Configuration;
    +import org.apache.stratum.configuration.PropertiesConfiguration;
    +import org.apache.stratum.exception.NestableException;
    +import org.apache.stratum.lifecycle.Configurable;
    +import org.apache.stratum.lifecycle.Initializable;
     
     /**
      * The implementation of Torque.
    @@ -84,9 +88,10 @@
      * @author <a href="mailto:magnus@handtolvur.is">Magnús Þór Torfason</a>
      * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
      * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
    - * @version $Id: Torque.java,v 1.42 2002/01/08 20:50:07 dlr Exp $
    + * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    + * @version $Id: Torque.java,v 1.43 2002/02/06 15:18:56 mpoeschl Exp $
      */
    -public class Torque
    +public class Torque implements Initializable, Configurable
     {
         /**
          * Name of property that specifies the default
    @@ -104,8 +109,8 @@
          */
         private static String defaultDBName;
     
    -    /** 
    -     * The global cache of database maps 
    +    /**
    +     * The global cache of database maps
          */
         private static Map dbMaps;
     
    @@ -118,13 +123,13 @@
         /**
          * The logging category.
          */
    -    private static Category category = 
    +    private static Category category =
             Category.getInstance(Torque.class.getName());
     
         /**
          * Torque-specific configuration.
          */
    -    private static ExtendedProperties configuration;
    +    private static Configuration configuration;
     
         /**
          * The connection pool monitor.
    @@ -144,6 +149,83 @@
          */
         private static List mapBuilders = new Vector();
     
    +
    +    /**
    +     * initialize Torque
    +     *
    +     * @see org.apache.stratum.lifecycle.Initializable
    +     */
    +    public void initialize() throws Exception
    +    {
    +        // FIX ME!!
    +        // duplicated code init(Configuration)
    +        if (configuration == null)
    +        {
    +            throw new Exception("Torque cannot be initialized without " +
    +                "a valid configuration. Please check the log files " +
    +                    "for further details.");
    +        }
    +
    +        // Setup log4j, I suppose we might want to deal with
    +        // systems other than log4j ...
    +        configureLogging();
    +
    +        // Now that we have dealt with processing the log4j properties
    +        // that may be contained in the configuration we will make the
    +        // configuration consist only of the remain torque specific
    +        // properties that are contained in the configuration. First
    +        // look for properties that are in the "torque" namespace.
    +        Configuration originalConf = configuration;
    +        configuration = configuration.subset("torque");
    +
    +        if (configuration == null || configuration.isEmpty())
    +        {
    +            // If there are no properties in the "torque" namespace
    +            // than try the "services.DatabaseService" namespace. This
    +            // will soon be deprecated.
    +            configuration = originalConf.subset("services.DatabaseService");
    +
    +            // the configuration may already have any prefixes stripped
    +            if (configuration == null || configuration.isEmpty())
    +            {
    +                configuration = originalConf;
    +            }
    +        }
    +
    +        dbMaps = new HashMap();
    +        pools = new HashMap();
    +        DBFactory.init(configuration);
    +
    +        isInit = true;
    +        for (Iterator i = mapBuilders.iterator(); i.hasNext(); )
    +        {
    +            //this will add any maps in this builder to the proper database map
    +            BasePeer.getMapBuilder((String)i.next());
    +        }
    +        // any further mapBuilders will be called/built on demand
    +        mapBuilders = null;
    +
    +
    +        // Create monitor thread
    +        monitor = new Monitor();
    +        // Indicate that this is a system thread. JVM will quit only when there
    +        // are no more active user threads. Settings threads spawned internally
    +        // by Turbine as daemons allows commandline applications using Turbine
    +        // to terminate in an orderly manner.
    +        monitor.setDaemon(true);
    +        monitor.start();
    +    }
    +
    +    /**
    +     * configure torque
    +     *
    +     * @see org.apache.stratum.lifecycle.Configurable
    +     */
    +    public void configure(Configuration config) throws NestableException
    +    {
    +        configuration = config;
    +    }
    +
         /**
          * Initialization of Torque with a properties file.
          *
    @@ -152,7 +234,7 @@
         public static void init(String configFile)
             throws Exception
         {
    -        ExtendedProperties c = new ExtendedProperties(configFile);
    +        Configuration c = (Configuration)new PropertiesConfiguration(configFile);
             init(c);
         }
     
    @@ -161,7 +243,7 @@
          *
          * @param c The Torque configuration.
          */
    -    public static void init(ExtendedProperties c)
    +    public static void init(Configuration c)
             throws Exception
         {
             Torque.setConfiguration(c);
    @@ -170,20 +252,20 @@
                 throw new Exception("Torque cannot be initialized without " +
                     "a valid configuration. Please check the log files " +
                         "for further details.");
    -        }            
    -        
    +        }
    +
             // Setup log4j, I suppose we might want to deal with
             // systems other than log4j ...
             configureLogging();
    -        
    +
             // Now that we have dealt with processing the log4j properties
             // that may be contained in the configuration we will make the
             // configuration consist only of the remain torque specific
    -        // properties that are contained in the configuration. First 
    +        // properties that are contained in the configuration. First
             // look for properties that are in the "torque" namespace.
    -        ExtendedProperties originalConf = configuration;
    +        Configuration originalConf = configuration;
             configuration = configuration.subset("torque");
    -        
    +
             if (configuration == null || configuration.isEmpty())
             {
                 // If there are no properties in the "torque" namespace
    @@ -195,7 +277,7 @@
                 if (configuration == null || configuration.isEmpty())
                 {
                     configuration = originalConf;
    -            }            
    +            }
             }
     
             dbMaps = new HashMap();
    @@ -203,14 +285,14 @@
             DBFactory.init(configuration);
     
             isInit = true;
    -        for ( Iterator i=mapBuilders.iterator(); i.hasNext(); ) 
    +        for (Iterator i = mapBuilders.iterator(); i.hasNext(); )
             {
                 //this will add any maps in this builder to the proper database map
                 BasePeer.getMapBuilder((String)i.next());
             }
             // any further mapBuilders will be called/built on demand
             mapBuilders = null;
    -        
    +
     
             // Create monitor thread
             monitor = new Monitor();
    @@ -230,7 +312,7 @@
         /**
          * Sets the configuration for Torque and all dependencies.
          */
    -    public static void setConfiguration(ExtendedProperties c)
    +    public static void setConfiguration(Configuration c)
         {
             configuration = c;
         }
    @@ -238,11 +320,11 @@
         /**
          * Get the configuration for this component.
          */
    -    public static ExtendedProperties getConfiguration()
    +    public static Configuration getConfiguration()
         {
             return configuration;
    -    }        
    -    
    +    }
    +
         /**
          * Configure the logging for this subsystem.
          */
    @@ -252,9 +334,9 @@
             {
                 // Get the applicationRoot for use in the log4j
                 // properties.
    -            String applicationRoot = 
    +            String applicationRoot =
                     getConfiguration().getString("torque.applicationRoot", ".");
    -            
    +
                 //!! Need a configurable log directory.
                 File logsDir = new File(applicationRoot, "logs");
     
    @@ -267,29 +349,29 @@
                 }
     
                 // Extract the log4j values out of the configuration and
    -            // place them in a Properties object so that we can 
    +            // place them in a Properties object so that we can
                 // use the log4j PropertyConfigurator.
                 Properties p = new Properties();
                 p.put("torque.applicationRoot", applicationRoot);
    -            
    +
                 Iterator i = getConfiguration().getKeys();
                 while (i.hasNext())
                 {
                     String key = (String) i.next();
    -                
    +
                     // We only want log4j properties.
                     if (key.startsWith("log4j") == false)
                     {
                         continue;
                     }
    -                
    +
                     // We have to deal with ExtendedProperties way
                     // of dealing with "," in properties which is to
                     // make them separate values. Log4j category
                     // properties contain commas so we must stick them
                     // back together for log4j.
                     String[] values = getConfiguration().getStringArray(key);
    -                
    +
                     String value;
                     if (values.length == 1)
                     {
    @@ -298,15 +380,15 @@
                     else
                     {
                         value = values[0] + "," + values[1];
    -                }                    
    -                
    +                }
    +
                     p.put(key, value);
    -            } 
    -            
    +            }
    +
                 PropertyConfigurator.configure(p);
                 category.info("Logging has been configured by Torque.");
             }
    -        
    +
         }
     
         /**
    @@ -482,7 +564,7 @@
         public static void registerMapBuilder(String className)
         {
             mapBuilders.add(className);
    -    } 
    +    }
     
         /**
          * Returns the specified property of the given database, or the empty
    @@ -835,7 +917,7 @@
                             .append(pool.getNbrAvailable()).append(" + ")
                             .append(pool.getNbrCheckedOut()).append(" = ")
                             .append(pool.getTotalCount());
    -                    
    +
                         category.info(buf.toString());
                     }
     
    @@ -865,10 +947,10 @@
             // same object.
             else if (defaultDBName == null)
             {
    -            defaultDBName = 
    +            defaultDBName =
                     configuration.getString(DATABASE_DEFAULT, DEFAULT_NAME);
             }
    -        
    +
             return defaultDBName;
         }
     
    
    
    
    1.20      +4 -3      jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBFactory.java
    
    Index: DBFactory.java
    ===================================================================
    RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBFactory.java,v
    retrieving revision 1.19
    retrieving revision 1.20
    diff -u -r1.19 -r1.20
    --- DBFactory.java 14 Dec 2001 22:14:06 -0000 1.19
    +++ DBFactory.java 6 Feb 2002 15:18:56 -0000 1.20
    @@ -56,8 +56,9 @@
     
     import java.util.Hashtable;
     import java.util.Iterator;
    -import org.apache.commons.collections.ExtendedProperties;
     import org.apache.log4j.Category;
    +import org.apache.stratum.configuration.Configuration;
    +
     
     /**
      * This class creates different {@link org.apache.torque.adapter.DB}
    @@ -68,7 +69,7 @@
      * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
      * @author <a href="mailto:ralf@reswi.ruhr.de">Ralf Stranzenbach</a>
      * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
    - * @version $Id: DBFactory.java,v 1.19 2001/12/14 22:14:06 brekke Exp $
    + * @version $Id: DBFactory.java,v 1.20 2002/02/06 15:18:56 mpoeschl Exp $
      */
     public class DBFactory
     {
    @@ -101,7 +102,7 @@
          * configuration is queried to get a list of JDBC drivers and
          * their associated adapters.
          */
    -    public static void init(ExtendedProperties configuration)
    +    public static void init(Configuration configuration)
         {
             adapters = new Hashtable();
             initializeDriverToAdapterMap();
    
    
    
    1.11      +5 -5      jakarta-turbine-torque/src/java/org/apache/torque/oid/IDBroker.java
    
    Index: IDBroker.java
    ===================================================================
    RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/oid/IDBroker.java,v
    retrieving revision 1.10
    retrieving revision 1.11
    diff -u -r1.10 -r1.11
    --- IDBroker.java 26 Nov 2001 23:46:16 -0000 1.10
    +++ IDBroker.java 6 Feb 2002 15:18:56 -0000 1.11
    @@ -64,8 +64,8 @@
     import java.util.Enumeration;
     import java.util.Hashtable;
     import java.util.List;
    -import org.apache.commons.collections.ExtendedProperties;
     import org.apache.log4j.Category;
    +import org.apache.stratum.configuration.Configuration;
     import org.apache.torque.Torque;
     import org.apache.torque.TorqueException;
     import org.apache.torque.map.DatabaseMap;
    @@ -113,7 +113,7 @@
      *
      * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
      * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
    - * @version $Id: IDBroker.java,v 1.10 2001/11/26 23:46:16 jmcnally Exp $
    + * @version $Id: IDBroker.java,v 1.11 2002/02/06 15:18:56 mpoeschl Exp $
      */
     public class IDBroker
         implements Runnable, IdGenerator
    @@ -196,7 +196,7 @@
          */
         private static final BigDecimal ONE = new BigDecimal("1");
     
    -    private ExtendedProperties configuration;
    +    private Configuration configuration;
     
         private static final String DB_IDBROKER_CLEVERQUANTITY =
             "idbroker.clever.quantity";
    @@ -219,7 +219,7 @@
         {
             this.tableMap = tMap;
             configuration = Torque.getConfiguration();
    -        
    +
             // Start the housekeeper thread only if prefetch has not been disabled
             if (configuration.getBoolean(DB_IDBROKER_PREFETCH, true))
             {
    @@ -270,7 +270,7 @@
             }
         }
     
    -    public void setConfiguration(ExtendedProperties configuration)
    +    public void setConfiguration(Configuration configuration)
         {
             this.configuration = configuration;
         }
    
    
    

  --
  To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
  For additional commands, e-mail: <ma...@jakarta.apache.org>