Coverage report

  %line %branch
org.apache.jetspeed.components.datasource.BoundDBCPDatasourceComponent
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.components.datasource;
 18  
 
 19  
 import javax.naming.NamingException;
 20  
 
 21  
 import org.apache.jetspeed.components.jndi.JNDIComponent;
 22  
 
 23  
 
 24  
 /**
 25  
  * Bound DBCP Data Source
 26  
  *
 27  
  * @author <a href="mailto:sweaver@apache.org">Scott Weaver</a>
 28  
  * @version $Id: BoundDBCPDatasourceComponent.java 516448 2007-03-09 16:25:47Z ate $
 29  
  */
 30  
 public class BoundDBCPDatasourceComponent extends DBCPDatasourceComponent
 31  
 {
 32  
     private JNDIComponent jndi;
 33  
     private String bindName;
 34  
 
 35  
     
 36  
     /* (non-Javadoc)
 37  
      * @see java.lang.Object#finalize()
 38  
      */
 39  
     protected void finalize() throws Throwable
 40  
     {
 41  0
         stop();
 42  0
         super.finalize();
 43  0
     }
 44  
     /**
 45  
      * 
 46  
      * @param user
 47  
      * @param password
 48  
      * @param driverName
 49  
      * @param connectURI
 50  
      * @param maxActive
 51  
      * @param maxWait
 52  
      * @param whenExhausted
 53  
      * @param autoCommit
 54  
      * @param bindName JNDI name to bind this <code>javax.sql.DataSource</code>
 55  
      * created by this class to.
 56  
      * @param jndi JNDIComponent we will use to bind.
 57  
      */
 58  
     public BoundDBCPDatasourceComponent(String user, String password, String driverName, String connectURI,
 59  
             int maxActive, class="keyword">int maxWait, byte whenExhausted, boolean autoCommit, String bindName, JNDIComponent jndi)
 60  
     {
 61  0
         super(user, password, driverName, connectURI, maxActive, maxWait, whenExhausted, autoCommit);
 62  0
         if(jndi == null)
 63  
         {
 64  0
             throw new IllegalArgumentException("jndi argument cannot be null for BoundDBCPDatasourceComponent");
 65  
         }
 66  
         
 67  0
         if(bindName == null)
 68  
         {
 69  0
             throw new IllegalArgumentException("bindName argument cannot be null for BoundDBCPDatasourceComponent");
 70  
         }
 71  
         
 72  0
         this.jndi = jndi;
 73  0
         this.bindName = bindName;
 74  
 
 75  0
     }
 76  
     /**
 77  
      * Same as {@link DBCPDatasourceComponent#start()}
 78  
      * but also binds these <code>javax.sql.DataSource</code>
 79  
      * created to the <code>bindName</code>.
 80  
      * 
 81  
      * @see org.picocontainer.Startable#start()
 82  
      */
 83  
     public void start()
 84  
     {        
 85  0
         super.start();
 86  
         try
 87  
         {
 88  0
             jndi.bindObject("comp/env/jdbc/"+bindName, getDatasource());
 89  0
             jndi.bindObject("jdbc/"+bindName, getDatasource());
 90  
         }
 91  0
         catch (NamingException e)
 92  
         {
 93  0
             IllegalStateException ise = new IllegalStateException("Naming exception "+e.toString());
 94  0
             ise.initCause(e);
 95  0
             throw ise;
 96  0
         }
 97  0
     }
 98  
 
 99  
     /* (non-Javadoc)
 100  
      * @see org.picocontainer.Startable#stop()
 101  
      */
 102  
     public void stop()
 103  
     {        
 104  
         try
 105  
         {
 106  0
             jndi.unbindObject("comp/env/jdbc/"+bindName);
 107  0
             jndi.unbindObject("jdbc/" + bindName);
 108  
         }
 109  0
         catch (NamingException e)
 110  
         {
 111  0
              throw new IllegalStateException("Naming exception "+e.toString());
 112  0
         }
 113  0
         super.stop();
 114  0
     }
 115  
 }

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