Registry.java
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package se.lil.om;
import java.util.ArrayList;
public class Registry {
private static ArrayList<OraMon> oraList = null;
public static boolean test = true;
public static synchronized ArrayList<OraMon> getList() {
if (oraList == null) {
oraList = new ArrayList<OraMon>();
}
return oraList;
}
public static synchronized OraMon findOrCreate(String conStr, String usrStr, String pwdStr) {
for (OraMon item : getList()) {
if(item.getConString().equals(conStr)) {
return item;
}
}
// Not found, create it
OraMon monitor = new OraMon(conStr, usrStr, pwdStr);
oraList.add(monitor);
return monitor;
}
public static synchronized OraMon find(String conStr) {
for (OraMon item : getList()) {
if(item.getConString().equals(conStr)) {
return item;
}
}
return null;
}
public static synchronized void remove(String conStr) {
OraMon mon = null;
for (OraMon item : getList()) {
if(item.getConString().equals(conStr)) {
mon = item;
}
}
if(mon != null) {
try {
mon.close();
} catch (Throwable t) {}
getList().remove(mon);
}
}
}