1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
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 | |
|
27 | |
|
28 | |
|
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 | |
} |