Coverage Report - org.apache.commons.dbcp.datasources.PerUserPoolDataSourceFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
PerUserPoolDataSourceFactory
7%
3/38
0%
0/36
10
 
 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  
 
 18  
 package org.apache.commons.dbcp.datasources;
 19  
 
 20  
 import java.io.IOException;
 21  
 import java.util.Map;
 22  
 
 23  
 import javax.naming.RefAddr;
 24  
 import javax.naming.Reference;
 25  
 
 26  
 /**
 27  
  * A JNDI ObjectFactory which creates <code>SharedPoolDataSource</code>s
 28  
  * 
 29  
  * @version $Revision: 1023401 $ $Date: 2010-10-16 21:54:24 -0400 (Sat, 16 Oct 2010) $
 30  
  */
 31  8
 public class PerUserPoolDataSourceFactory
 32  
     extends InstanceKeyObjectFactory
 33  
 {
 34  2
     private static final String PER_USER_POOL_CLASSNAME =
 35  
         PerUserPoolDataSource.class.getName();
 36  
 
 37  
     protected boolean isCorrectClass(String className) {
 38  4
         return PER_USER_POOL_CLASSNAME.equals(className);
 39  
     }
 40  
 
 41  
     protected InstanceKeyDataSource getNewInstance(Reference ref) 
 42  
         throws IOException, ClassNotFoundException {
 43  0
         PerUserPoolDataSource pupds =  new PerUserPoolDataSource();
 44  0
         RefAddr ra = ref.get("defaultMaxActive");
 45  0
         if (ra != null && ra.getContent() != null) {
 46  0
             pupds.setDefaultMaxActive(
 47  
                 Integer.parseInt(ra.getContent().toString()));
 48  
         }
 49  
 
 50  0
         ra = ref.get("defaultMaxIdle");
 51  0
         if (ra != null && ra.getContent() != null) {
 52  0
             pupds.setDefaultMaxIdle(
 53  
                 Integer.parseInt(ra.getContent().toString()));
 54  
         }
 55  
 
 56  0
         ra = ref.get("defaultMaxWait");
 57  0
         if (ra != null && ra.getContent() != null) {
 58  0
             pupds.setDefaultMaxWait(
 59  
                 Integer.parseInt(ra.getContent().toString()));
 60  
         }
 61  
 
 62  0
         ra = ref.get("perUserDefaultAutoCommit");
 63  0
         if (ra != null  && ra.getContent() != null) {
 64  0
             byte[] serialized = (byte[]) ra.getContent();
 65  0
             pupds.perUserDefaultAutoCommit = (Map) deserialize(serialized);
 66  
         }
 67  
 
 68  0
         ra = ref.get("perUserDefaultTransactionIsolation");
 69  0
         if (ra != null  && ra.getContent() != null) {
 70  0
             byte[] serialized = (byte[]) ra.getContent();
 71  0
             pupds.perUserDefaultTransactionIsolation = 
 72  
                 (Map) deserialize(serialized);
 73  
         }
 74  
 
 75  0
         ra = ref.get("perUserMaxActive");
 76  0
         if (ra != null  && ra.getContent() != null) {
 77  0
             byte[] serialized = (byte[]) ra.getContent();
 78  0
             pupds.perUserMaxActive = (Map) deserialize(serialized);
 79  
         }
 80  
         
 81  0
         ra = ref.get("perUserMaxIdle");
 82  0
         if (ra != null  && ra.getContent() != null) {
 83  0
             byte[] serialized = (byte[]) ra.getContent();
 84  0
             pupds.perUserMaxIdle = (Map) deserialize(serialized);
 85  
         }
 86  
         
 87  0
         ra = ref.get("perUserMaxWait");
 88  0
         if (ra != null  && ra.getContent() != null) {
 89  0
             byte[] serialized = (byte[]) ra.getContent();
 90  0
             pupds.perUserMaxWait = (Map) deserialize(serialized);
 91  
         }
 92  
                 
 93  0
         ra = ref.get("perUserDefaultReadOnly");
 94  0
         if (ra != null  && ra.getContent() != null) {
 95  0
             byte[] serialized = (byte[]) ra.getContent();
 96  0
             pupds.perUserDefaultReadOnly = (Map) deserialize(serialized);
 97  
         }
 98  0
         return pupds;
 99  
     }            
 100  
 }
 101