Fixed register/removeListener methods to not re-add once initialized.

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@498865 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Srinivasa Segu 2007-01-23 00:15:15 +00:00
parent 95544768f6
commit 5dddb15cb3
1 changed files with 6 additions and 4 deletions

View File

@ -45,9 +45,10 @@ public abstract class AbstractEventManager implements EventManager {
if (listener == null) if (listener == null)
return; return;
if (_firing) { if (_firing) {
if (_newListeners == null) if (_newListeners == null) {
_newListeners = newListenerCollection(); _newListeners = newListenerCollection();
_newListeners.addAll(_listeners); _newListeners.addAll(_listeners);
}
_newListeners.add(listener); _newListeners.add(listener);
} else { } else {
if (_listeners == null) if (_listeners == null)
@ -63,9 +64,10 @@ public abstract class AbstractEventManager implements EventManager {
if (listener == null) if (listener == null)
return false; return false;
if (_firing && _listeners.contains(listener)) { if (_firing && _listeners.contains(listener)) {
if (_newListeners == null) if (_newListeners == null) {
_newListeners = newListenerCollection(); _newListeners = newListenerCollection();
_newListeners.addAll(_listeners); _newListeners.addAll(_listeners);
}
return _newListeners.remove(listener); return _newListeners.remove(listener);
} }
return _listeners != null && _listeners.remove(listener); return _listeners != null && _listeners.remove(listener);