bloritsch    01/03/12 08:58:45

  Modified:    src/java/org/apache/avalon/util/datasource
                        DataSourceComponent.java J2eeDataSource.java
                        JdbcDataSource.java
               src/java/org/apache/avalon/util/datasource/test
                        DataSourceTestlet.java
  Log:
  Upgraded Avalon DataSources to use new Configuration scheme
  
  Revision  Changes    Path
  1.2       +11 -11    
jakarta-avalon/src/java/org/apache/avalon/util/datasource/DataSourceComponent.java
  
  Index: DataSourceComponent.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/src/java/org/apache/avalon/util/datasource/DataSourceComponent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DataSourceComponent.java  2001/02/24 03:59:38     1.1
  +++ DataSourceComponent.java  2001/03/12 16:58:35     1.2
  @@ -1,30 +1,30 @@
  -/* 
  - * Copyright (C) The Apache Software Foundation. All rights reserved. 
  - * 
  - * This software is published under the terms of the Apache Software License 
  - * version 1.1, a copy of which has been included with this distribution in 
  - * the LICENSE file. 
  - */ 
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE file.
  + */
   package org.apache.avalon.util.datasource;
   
   import java.sql.Connection;
   import java.sql.SQLException;
   import org.apache.avalon.Component;
  -import org.apache.avalon.Configurable;
  +import org.apache.avalon.configuration.Configurable;
   import org.apache.avalon.ThreadSafe;
   
   /**
    * The standard interface for DataSources in Avalon.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/02/24 03:59:38 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/03/12 16:58:35 $
    */
  -public interface DataSourceComponent 
  +public interface DataSourceComponent
       extends Component, Configurable, ThreadSafe
   {
       /**
        * Gets the Connection to the database
        */
  -    Connection getConnection() 
  +    Connection getConnection()
           throws SQLException;
   }
  
  
  
  1.2       +15 -15    
jakarta-avalon/src/java/org/apache/avalon/util/datasource/J2eeDataSource.java
  
  Index: J2eeDataSource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/src/java/org/apache/avalon/util/datasource/J2eeDataSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- J2eeDataSource.java       2001/02/24 03:59:38     1.1
  +++ J2eeDataSource.java       2001/03/12 16:58:36     1.2
  @@ -1,10 +1,10 @@
  -/* 
  - * Copyright (C) The Apache Software Foundation. All rights reserved. 
  - * 
  - * This software is published under the terms of the Apache Software License 
  - * version 1.1, a copy of which has been included with this distribution in 
  - * the LICENSE file. 
  - */ 
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE file.
  + */
   package org.apache.avalon.util.datasource;
   
   import java.sql.Connection;
  @@ -13,8 +13,8 @@
   import javax.naming.InitialContext;
   import javax.naming.NamingException;
   import javax.sql.DataSource;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  +import org.apache.avalon.configuration.Configuration;
  +import org.apache.avalon.configuration.ConfigurationException;
   import org.apache.avalon.AbstractLoggable;
   
   /**
  @@ -23,9 +23,9 @@
    * J2EE container pools the datasources properly.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/02/24 03:59:38 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/03/12 16:58:36 $
    */
  -public class J2eeDataSource 
  +public class J2eeDataSource
       extends AbstractLoggable
       implements DataSourceComponent
   {
  @@ -45,7 +45,7 @@
       public void configure( final Configuration configuration )
           throws ConfigurationException
       {
  -        if( null == m_dataSource ) 
  +        if( null == m_dataSource )
           {
               final String databaseName = configuration.getChild("dbname").getValue();
   
  @@ -53,8 +53,8 @@
               {
                   final Context initialContext = new InitialContext();
                   m_dataSource = (DataSource)initialContext.lookup( JDBC_NAME + 
databaseName );
  -            } 
  -            catch( final NamingException ne ) 
  +            }
  +            catch( final NamingException ne )
               {
                   getLogger().error( "Problem with JNDI lookup of datasource", ne );
                   throw new ConfigurationException( "Could not use JNDI to find 
datasource", ne );
  @@ -64,7 +64,7 @@
   
       /** Get the database connection */
       public Connection getConnection()
  -        throws SQLException 
  +        throws SQLException
       {
           if( null == m_dataSource )
           {
  
  
  
  1.3       +3 -3      
jakarta-avalon/src/java/org/apache/avalon/util/datasource/JdbcDataSource.java
  
  Index: JdbcDataSource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/src/java/org/apache/avalon/util/datasource/JdbcDataSource.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JdbcDataSource.java       2001/03/09 15:06:49     1.2
  +++ JdbcDataSource.java       2001/03/12 16:58:37     1.3
  @@ -9,8 +9,8 @@
   
   import java.sql.Connection;
   import java.sql.SQLException;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  +import org.apache.avalon.configuration.Configuration;
  +import org.apache.avalon.configuration.ConfigurationException;
   import org.apache.avalon.Disposable;
   import org.apache.avalon.AbstractLoggable;
   
  @@ -20,7 +20,7 @@
    * <code>java.sql.DriverManager</code>.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/03/09 15:06:49 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/03/12 16:58:37 $
    */
   public class JdbcDataSource
       extends AbstractLoggable
  
  
  
  1.3       +26 -26    
jakarta-avalon/src/java/org/apache/avalon/util/datasource/test/DataSourceTestlet.java
  
  Index: DataSourceTestlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/src/java/org/apache/avalon/util/datasource/test/DataSourceTestlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DataSourceTestlet.java    2001/02/24 07:28:21     1.2
  +++ DataSourceTestlet.java    2001/03/12 16:58:43     1.3
  @@ -10,9 +10,9 @@
   import java.sql.Connection;
   import java.sql.SQLException;
   import java.util.Random;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  -import org.apache.avalon.DefaultConfiguration;
  +import org.apache.avalon.configuration.Configuration;
  +import org.apache.avalon.configuration.ConfigurationException;
  +import org.apache.avalon.configuration.DefaultConfiguration;
   import org.apache.avalon.util.datasource.DataSourceComponent;
   import org.apache.avalon.util.datasource.JdbcDataSource;
   import org.apache.log.LogKit;
  @@ -25,7 +25,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
    */
  -public class DataSourceTestlet 
  +public class DataSourceTestlet
       extends AbstractTestlet
   {
       static final Configuration conf;
  @@ -51,39 +51,39 @@
   
           LogKit.setGlobalPriority( org.apache.log.Priority.INFO );
   
  -        try 
  +        try
           {
               Class.forName( "Your Driver Class Here" );
  -        } 
  +        }
           catch( final Exception e )
           {
               LogKit.getLoggerFor( "test" ).error( e.getMessage(), e );
           }
       }
   
  -    public void testOverAllocation() 
  +    public void testOverAllocation()
       {
           boolean result = false;
           JdbcDataSource ds = new JdbcDataSource();
           ds.setLogger( LogKit.getLoggerFor( "test" ) );
   
  -        try 
  +        try
           {
               ds.configure( conf );
  -        } 
  +        }
           catch( final ConfigurationException ce )
           {
               assert( "Over Allocation Test", false );
           }
   
  -        try 
  +        try
           {
               for( int i = 0; i < 11; i++ )
               {
                   ds.getConnection();
               }
  -        } 
  -        catch( final SQLException se ) 
  +        }
  +        catch( final SQLException se )
           {
               result = true;
               LogKit.getLoggerFor( "test" ).info( "The test was successful" );
  @@ -92,16 +92,16 @@
           assert( "Over Allocation Test", result );
       }
   
  -    public void testNormalUse() 
  +    public void testNormalUse()
       {
           boolean result = true;
           JdbcDataSource ds = new JdbcDataSource();
           ds.setLogger( LogKit.getLoggerFor( "test" ) );
   
  -        try 
  +        try
           {
               ds.configure( conf );
  -        } 
  +        }
           catch( final ConfigurationException ce )
           {
               LogKit.getLoggerFor( "test" ).error( ce.getMessage(), ce );
  @@ -119,13 +119,13 @@
               try
               {
                   Thread.sleep( 100 );
  -            } 
  +            }
               catch( final InterruptedException ie )
               {
                   // Ignore
               }
           }
  -        
  +
           LogKit.getLoggerFor( "test" ).
               info( "If you saw no failure messages, then the test passed" );
           assert( "Normal Use Test", result );
  @@ -134,22 +134,22 @@
       public void runDBTest( final DataSourceComponent datasource )
       {
           long end = System.currentTimeMillis() + 5000; // run for 5 seconds
  -        
  +
           while( System.currentTimeMillis() < end )
           {
  -            try 
  +            try
               {
                   Connection con = datasource.getConnection();
                   long sleeptime = (long)(Math.random() * 100.0);
                   Thread.sleep( sleeptime );
                   con.close();
  -            } 
  +            }
               catch( final SQLException se )
               {
                   LogKit.getLoggerFor( "test" ).info( "Failed to get Connection, test 
failed" );
                   assert( "Normal Use Test", false );
               }
  -            catch( final InterruptedException ie ) 
  +            catch( final InterruptedException ie )
               {
                   // Ignore
               }
  @@ -157,20 +157,20 @@
       }
   }
   
  -class ConnectionThread 
  +class ConnectionThread
       implements Runnable
   {
       protected DataSourceComponent datasource;
       protected DataSourceTestlet testlet;
   
  -    ConnectionThread( final DataSourceTestlet testlet, 
  -                      final DataSourceComponent datasource ) 
  +    ConnectionThread( final DataSourceTestlet testlet,
  +                      final DataSourceComponent datasource )
       {
           this.datasource = datasource;
           this.testlet = testlet;
       }
  -    
  -    public void run() 
  +
  +    public void run()
       {
           testlet.runDBTest( datasource );
       }
  
  
  

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

Reply via email to