Coverage Report - net.admin4j.jdbc.driver.ConnectionRegistry
 
Classes in this File Line Coverage Branch Coverage Complexity
ConnectionRegistry
85%
6/7
N/A
1
 
 1  
 /*
 2  
  * This software is licensed under the Apache License, Version 2.0
 3  
  * (the "License") agreement; you may not use this file except in compliance with
 4  
  * the License.  You may obtain a copy of the License at
 5  
  * 
 6  
  *      http://www.apache.org/licenses/LICENSE-2.0
 7  
  * 
 8  
  * Unless required by applicable law or agreed to in writing, software
 9  
  * distributed under the License is distributed on an "AS IS" BASIS,
 10  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11  
  * See the License for the specific language governing permissions and
 12  
  * limitations under the License.
 13  
  */
 14  
 package net.admin4j.jdbc.driver;
 15  
 
 16  
 import java.util.HashSet;
 17  
 import java.util.Map;
 18  
 import java.util.Set;
 19  
 import java.util.concurrent.ConcurrentHashMap;
 20  
 
 21  
 import net.admin4j.deps.commons.lang3.Validate;
 22  
 import net.admin4j.jdbc.driver.sql.ConnectionWrapper30Base;
 23  
 import net.admin4j.util.annotate.PackageRestrictions;
 24  
 
 25  
 /**
 26  
  * Keeps track of all active connections.
 27  
  * @author D. Ashmore
 28  
  * @since 1.0
 29  
  */
 30  
 @PackageRestrictions({"net.admin4j","java","javax"})
 31  0
 public class ConnectionRegistry {
 32  
         
 33  9
         private static Map<ConnectionWrapper30Base, ConnectionWrapper30Base> registryMap = new ConcurrentHashMap<ConnectionWrapper30Base, ConnectionWrapper30Base>();
 34  
         
 35  
         public static void register(ConnectionWrapper30Base conn) {
 36  
                 Validate.notNull(conn, "Null Connection not allowed.");
 37  18
                 registryMap.put(conn, conn);
 38  18
         }
 39  
         
 40  
         public static void unRegister(ConnectionWrapper30Base conn) {
 41  
                 Validate.notNull(conn, "Null Connection not allowed.");
 42  15
                 registryMap.remove(conn);
 43  15
         }
 44  
         
 45  
         public static Set<ConnectionWrapper30Base> getCurrentConnectionSet() {
 46  24
                 return new HashSet<ConnectionWrapper30Base>(registryMap.keySet());
 47  
         }
 48  
 
 49  
 }