summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJani Laakso <jani.laakso@itmill.com>2008-01-31 11:13:34 +0000
committerJani Laakso <jani.laakso@itmill.com>2008-01-31 11:13:34 +0000
commit235f563f75aeff7e20783b83ba57e43ac5810548 (patch)
tree27c584461e98b2173c0b5eefe3baa2ff395e684c /src
parentaf23b1effd57a89deda86e8a33c737b9cb9115e8 (diff)
downloadvaadin-framework-235f563f75aeff7e20783b83ba57e43ac5810548.tar.gz
vaadin-framework-235f563f75aeff7e20783b83ba57e43ac5810548.zip
Concurrency issues fixed even further.
svn changeset:3682/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/event/EventRouter.java43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/com/itmill/toolkit/event/EventRouter.java b/src/com/itmill/toolkit/event/EventRouter.java
index 78f8a77df1..761a6fe9aa 100644
--- a/src/com/itmill/toolkit/event/EventRouter.java
+++ b/src/com/itmill/toolkit/event/EventRouter.java
@@ -34,12 +34,10 @@ public class EventRouter implements MethodEventSource {
* use the default documentation from implemented interface.
*/
public void addListener(Class eventType, Object object, Method method) {
-
- if (listenerList == null) {
- listenerList = Collections.synchronizedSet(new LinkedHashSet());
- }
-
synchronized (listenerList) {
+ if (listenerList == null) {
+ listenerList = Collections.synchronizedSet(new LinkedHashSet());
+ }
listenerList.add(new ListenerMethod(eventType, object, method));
}
}
@@ -50,12 +48,10 @@ public class EventRouter implements MethodEventSource {
* here, we use the default documentation from implemented interface.
*/
public void addListener(Class eventType, Object object, String methodName) {
-
- if (listenerList == null) {
- listenerList = Collections.synchronizedSet(new LinkedHashSet());
- }
-
synchronized (listenerList) {
+ if (listenerList == null) {
+ listenerList = Collections.synchronizedSet(new LinkedHashSet());
+ }
listenerList.add(new ListenerMethod(eventType, object, methodName));
}
}
@@ -66,8 +62,8 @@ public class EventRouter implements MethodEventSource {
* interface.
*/
public void removeListener(Class eventType, Object target) {
- if (listenerList != null) {
- synchronized (listenerList) {
+ synchronized (listenerList) {
+ if (listenerList != null) {
final Iterator i = listenerList.iterator();
while (i.hasNext()) {
try {
@@ -90,9 +86,8 @@ public class EventRouter implements MethodEventSource {
* implemented interface.
*/
public void removeListener(Class eventType, Object target, Method method) {
-
- if (listenerList != null) {
- synchronized (listenerList) {
+ synchronized (listenerList) {
+ if (listenerList != null) {
final Iterator i = listenerList.iterator();
while (i.hasNext()) {
try {
@@ -128,9 +123,9 @@ public class EventRouter implements MethodEventSource {
throw new IllegalArgumentException();
}
- // Remove the listeners
- if (listenerList != null) {
- synchronized (listenerList) {
+ synchronized (listenerList) {
+ // Remove the listeners
+ if (listenerList != null) {
final Iterator i = listenerList.iterator();
while (i.hasNext()) {
try {
@@ -145,6 +140,7 @@ public class EventRouter implements MethodEventSource {
}
}
}
+
}
/**
@@ -164,11 +160,12 @@ public class EventRouter implements MethodEventSource {
* the Event to be sent to all listeners.
*/
public void fireEvent(EventObject event) {
- // It is not necessary to send any events if there are no listeners
- if (listenerList != null) {
- // Send the event to all listeners. The listeners themselves
- // will filter out unwanted events.
- synchronized (listenerList) {
+ synchronized (listenerList) {
+ // It is not necessary to send any events if there are no listeners
+ if (listenerList != null) {
+ // Send the event to all listeners. The listeners themselves
+ // will filter out unwanted events.
+
final Iterator i = listenerList.iterator();
while (i.hasNext()) {
((ListenerMethod) i.next()).receiveEvent(event);