|
@@ -25,7 +25,7 @@ package com.dmdirc.util;
|
25
|
25
|
import java.util.Collection;
|
26
|
26
|
import java.util.HashMap;
|
27
|
27
|
import java.util.Map;
|
28
|
|
-import java.util.concurrent.ConcurrentSkipListSet;
|
|
28
|
+import java.util.concurrent.CopyOnWriteArrayList;
|
29
|
29
|
|
30
|
30
|
/**
|
31
|
31
|
* Represents a list of event listeners, similar to EventListenerList, but
|
|
@@ -34,9 +34,6 @@ import java.util.concurrent.ConcurrentSkipListSet;
|
34
|
34
|
* @author chris
|
35
|
35
|
*/
|
36
|
36
|
public class ListenerList {
|
37
|
|
-
|
38
|
|
- /** The comparator to use. */
|
39
|
|
- protected static EqualComparator COMPARATOR = new EqualComparator();
|
40
|
37
|
|
41
|
38
|
/** The map of class->listener or string->listener that we're using. */
|
42
|
39
|
private final Map<Object, Collection<Object>> listeners
|
|
@@ -57,7 +54,7 @@ public class ListenerList {
|
57
|
54
|
*/
|
58
|
55
|
public <T> void add(final Class<T> listenerType, final T listener) {
|
59
|
56
|
if (!listeners.containsKey(listenerType)) {
|
60
|
|
- listeners.put(listenerType, new ConcurrentSkipListSet<Object>(COMPARATOR));
|
|
57
|
+ listeners.put(listenerType, new CopyOnWriteArrayList<Object>());
|
61
|
58
|
}
|
62
|
59
|
|
63
|
60
|
listeners.get(listenerType).add(listener);
|
|
@@ -71,7 +68,7 @@ public class ListenerList {
|
71
|
68
|
*/
|
72
|
69
|
public void add(final String listenerType, final Object listener) {
|
73
|
70
|
if (!listeners.containsKey(listenerType)) {
|
74
|
|
- listeners.put(listenerType, new ConcurrentSkipListSet<Object>(COMPARATOR));
|
|
71
|
+ listeners.put(listenerType, new CopyOnWriteArrayList<Object>());
|
75
|
72
|
}
|
76
|
73
|
|
77
|
74
|
listeners.get(listenerType).add(listener);
|
|
@@ -111,7 +108,7 @@ public class ListenerList {
|
111
|
108
|
if (listeners.containsKey(listenerType)) {
|
112
|
109
|
return (Collection<T>) listeners.get(listenerType);
|
113
|
110
|
} else {
|
114
|
|
- return new ConcurrentSkipListSet<T>(COMPARATOR);
|
|
111
|
+ return new CopyOnWriteArrayList<T>();
|
115
|
112
|
}
|
116
|
113
|
}
|
117
|
114
|
|
|
@@ -125,7 +122,7 @@ public class ListenerList {
|
125
|
122
|
if (listeners.containsKey(listenerType)) {
|
126
|
123
|
return listeners.get(listenerType);
|
127
|
124
|
} else {
|
128
|
|
- return new ConcurrentSkipListSet<Object>(COMPARATOR);
|
|
125
|
+ return new CopyOnWriteArrayList<Object>();
|
129
|
126
|
}
|
130
|
127
|
}
|
131
|
128
|
|