Coverage report

  %line %branch
org.apache.torque.dsfactory.PerUserPoolDataSourceFactory
0% 
0% 

 1  
 package org.apache.torque.dsfactory;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2004 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import javax.sql.ConnectionPoolDataSource;
 20  
 import javax.sql.DataSource;
 21  
 
 22  
 import org.apache.commons.configuration.Configuration;
 23  
 
 24  
 import org.apache.commons.dbcp.datasources.PerUserPoolDataSource;
 25  
 
 26  
 import org.apache.commons.logging.Log;
 27  
 import org.apache.commons.logging.LogFactory;
 28  
 
 29  
 import org.apache.torque.Torque;
 30  
 import org.apache.torque.TorqueException;
 31  
 
 32  
 /**
 33  
  * A factory that looks up the DataSource using the JDBC2 pool methods.
 34  
  *
 35  
  * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
 36  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 37  
  * @version $Id: PerUserPoolDataSourceFactory.java,v 1.1.2.2 2004/05/20 04:35:14 seade Exp $
 38  
  */
 39  0
 public class PerUserPoolDataSourceFactory
 40  
     extends AbstractDataSourceFactory
 41  
     implements DataSourceFactory
 42  
 {
 43  
 
 44  
     /** The log. */
 45  0
     private static Log log 
 46  0
             = LogFactory.getLog(PerUserPoolDataSourceFactory.class);
 47  
 
 48  
     /** The wrapped <code>DataSource</code>. */
 49  
     private DataSource ds;
 50  
 
 51  
     /**
 52  
      * @see org.apache.torque.dsfactory.DataSourceFactory#getDataSource
 53  
      */
 54  
     public DataSource getDataSource()
 55  
     {
 56  0
         return ds;
 57  
     }
 58  
 
 59  
     /**
 60  
      * @see org.apache.torque.dsfactory.DataSourceFactory#initialize
 61  
      */
 62  
     public void initialize(Configuration configuration) throws TorqueException
 63  
     {
 64  0
         if (configuration == null)
 65  
         {
 66  0
             throw new TorqueException(
 67  
                 "Torque cannot be initialized without a valid configuration. "
 68  
                 + "Please check the log files for further details.");
 69  
         }
 70  
 
 71  0
         ConnectionPoolDataSource cpds = initCPDS(configuration);
 72  0
         PerUserPoolDataSource ds = initJdbc2Pool(configuration);
 73  0
         ds.setConnectionPoolDataSource(cpds);
 74  0
         this.ds = ds;
 75  0
     }
 76  
 
 77  
     /**
 78  
      * Initializes the Jdbc2PoolDataSource.
 79  
      *
 80  
      * @param configuration where to read the settings from
 81  
      * @throws TorqueException if a property set fails
 82  
      * @return a configured <code>Jdbc2PoolDataSource</code>
 83  
      */
 84  
     private PerUserPoolDataSource initJdbc2Pool(Configuration configuration)
 85  
         throws TorqueException
 86  
     {
 87  0
         log.debug("Starting initJdbc2Pool");
 88  0
         PerUserPoolDataSource ds = new PerUserPoolDataSource();
 89  0
         Configuration c = Torque.getConfiguration();
 90  
 
 91  0
         if (c == null)
 92  
         {
 93  0
             log.warn("Global Configuration not set,"
 94  
                     + " no Default pool data source configured!");
 95  
         }
 96  
         else
 97  
         {
 98  0
             Configuration conf = c.subset(DEFAULT_POOL_KEY);
 99  0
             applyConfiguration(conf, ds);
 100  
         }
 101  
 
 102  0
         Configuration conf = configuration.subset(POOL_KEY);
 103  0
         applyConfiguration(conf, ds);
 104  0
         return ds;
 105  
     }
 106  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.