Lines 37-48
Link Here
|
37 |
/** |
37 |
/** |
38 |
* The HashMap that holds the data about the already-constructed Verifier instances. |
38 |
* The HashMap that holds the data about the already-constructed Verifier instances. |
39 |
*/ |
39 |
*/ |
40 |
private static Map hashMap = new HashMap(); |
40 |
private static ThreadLocal hashMap = new ThreadLocal() { |
|
|
41 |
protected Object initialValue() { |
42 |
return new HashMap(); |
43 |
} |
44 |
}; |
45 |
|
41 |
/** |
46 |
/** |
42 |
* The VerifierFactoryObserver instances that observe the VerifierFactory. |
47 |
* The VerifierFactoryObserver instances that observe the VerifierFactory. |
43 |
*/ |
48 |
*/ |
44 |
private static List observers = new Vector(); |
49 |
private static ThreadLocal observers = new ThreadLocal() { |
45 |
|
50 |
protected Object initialValue() { |
|
|
51 |
return new Vector(); |
52 |
} |
53 |
}; |
46 |
|
54 |
|
47 |
/** |
55 |
/** |
48 |
* The VerifierFactory is not instantiable. |
56 |
* The VerifierFactory is not instantiable. |
Lines 57-66
Link Here
|
57 |
* @return the (only) verifier responsible for the class with the given name. |
65 |
* @return the (only) verifier responsible for the class with the given name. |
58 |
*/ |
66 |
*/ |
59 |
public static Verifier getVerifier( String fully_qualified_classname ) { |
67 |
public static Verifier getVerifier( String fully_qualified_classname ) { |
60 |
Verifier v = (Verifier) (hashMap.get(fully_qualified_classname)); |
68 |
HashMap map = (HashMap) hashMap.get(); |
|
|
69 |
Verifier v = (Verifier) (map.get(fully_qualified_classname)); |
61 |
if (v == null) { |
70 |
if (v == null) { |
62 |
v = new Verifier(fully_qualified_classname); |
71 |
v = new Verifier(fully_qualified_classname); |
63 |
hashMap.put(fully_qualified_classname, v); |
72 |
map.put(fully_qualified_classname, v); |
64 |
notify(fully_qualified_classname); |
73 |
notify(fully_qualified_classname); |
65 |
} |
74 |
} |
66 |
return v; |
75 |
return v; |
Lines 72-78
Link Here
|
72 |
*/ |
81 |
*/ |
73 |
private static void notify( String fully_qualified_classname ) { |
82 |
private static void notify( String fully_qualified_classname ) { |
74 |
// notify the observers |
83 |
// notify the observers |
75 |
Iterator i = observers.iterator(); |
84 |
Iterator i = ((Vector) observers.get()).iterator(); |
76 |
while (i.hasNext()) { |
85 |
while (i.hasNext()) { |
77 |
VerifierFactoryObserver vfo = (VerifierFactoryObserver) i.next(); |
86 |
VerifierFactoryObserver vfo = (VerifierFactoryObserver) i.next(); |
78 |
vfo.update(fully_qualified_classname); |
87 |
vfo.update(fully_qualified_classname); |
Lines 88-95
Link Here
|
88 |
* referenced class files. |
97 |
* referenced class files. |
89 |
*/ |
98 |
*/ |
90 |
public static Verifier[] getVerifiers() { |
99 |
public static Verifier[] getVerifiers() { |
91 |
Verifier[] vs = new Verifier[hashMap.values().size()]; |
100 |
HashMap map = (HashMap) hashMap.get(); |
92 |
return (Verifier[]) (hashMap.values().toArray(vs)); // Because vs is big enough, vs is used to store the values into and returned! |
101 |
Verifier[] vs = new Verifier[map.values().size()]; |
|
|
102 |
return (Verifier[]) (map.values().toArray(vs)); // Because vs is big enough, vs is used to store the values into and returned! |
93 |
} |
103 |
} |
94 |
|
104 |
|
95 |
|
105 |
|
Lines 97-103
Link Here
|
97 |
* Adds the VerifierFactoryObserver o to the list of observers. |
107 |
* Adds the VerifierFactoryObserver o to the list of observers. |
98 |
*/ |
108 |
*/ |
99 |
public static void attach( VerifierFactoryObserver o ) { |
109 |
public static void attach( VerifierFactoryObserver o ) { |
100 |
observers.add(o); |
110 |
((Vector) observers.get()).add(o); |
101 |
} |
111 |
} |
102 |
|
112 |
|
103 |
|
113 |
|
Lines 105-110
Link Here
|
105 |
* Removes the VerifierFactoryObserver o from the list of observers. |
115 |
* Removes the VerifierFactoryObserver o from the list of observers. |
106 |
*/ |
116 |
*/ |
107 |
public static void detach( VerifierFactoryObserver o ) { |
117 |
public static void detach( VerifierFactoryObserver o ) { |
108 |
observers.remove(o); |
118 |
((Vector) observers.get()).remove(o); |
109 |
} |
119 |
} |
110 |
} |
120 |
} |