I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit d241afcb authored by zzz's avatar zzz
Browse files

* EventDispatcher: Minor cleanups and comments

parent 61525783
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,8 @@ import java.util.Set; ...@@ -31,6 +31,8 @@ import java.util.Set;
* public Object waitEventValue(String n) { return _event.waitEventValue(n); } * public Object waitEventValue(String n) { return _event.waitEventValue(n); }
* </code> * </code>
* *
* Deprecated - Used only by I2PTunnel
*
* @author human * @author human
*/ */
public interface EventDispatcher { public interface EventDispatcher {
...@@ -101,4 +103,4 @@ public interface EventDispatcher { ...@@ -101,4 +103,4 @@ public interface EventDispatcher {
* @return value specified for that event * @return value specified for that event
*/ */
public Object waitEventValue(String name); public Object waitEventValue(String name);
} }
\ No newline at end of file
...@@ -24,6 +24,8 @@ import java.util.Set; ...@@ -24,6 +24,8 @@ import java.util.Set;
* each object it is used by, ala: * each object it is used by, ala:
* <code>private final EventDispatcher _event = new EventDispatcher();</code> * <code>private final EventDispatcher _event = new EventDispatcher();</code>
* *
* Deprecated - Used only by I2PTunnel
*
* If there is anything in here that doesn't make sense, turn off * If there is anything in here that doesn't make sense, turn off
* your computer and go fly a kite - (c) 2004 by jrandom * your computer and go fly a kite - (c) 2004 by jrandom
...@@ -32,10 +34,10 @@ import java.util.Set; ...@@ -32,10 +34,10 @@ import java.util.Set;
*/ */
public class EventDispatcherImpl implements EventDispatcher { public class EventDispatcherImpl implements EventDispatcher {
private final static Log _log = new Log(EventDispatcherImpl.class); //private final static Log _log = new Log(EventDispatcherImpl.class);
private boolean _ignore = false; private boolean _ignore = false;
private /* FIXME final FIXME */ HashMap _events = new HashMap(4); private final HashMap _events = new HashMap(4);
private final ArrayList _attached = new ArrayList(); private final ArrayList _attached = new ArrayList();
public EventDispatcher getEventDispatcher() { public EventDispatcher getEventDispatcher() {
...@@ -45,7 +47,7 @@ public class EventDispatcherImpl implements EventDispatcher { ...@@ -45,7 +47,7 @@ public class EventDispatcherImpl implements EventDispatcher {
public void attachEventDispatcher(EventDispatcher ev) { public void attachEventDispatcher(EventDispatcher ev) {
if (ev == null) return; if (ev == null) return;
synchronized (_attached) { synchronized (_attached) {
_log.debug(this.hashCode() + ": attaching EventDispatcher " + ev.hashCode()); //_log.debug(this.hashCode() + ": attaching EventDispatcher " + ev.hashCode());
_attached.add(ev); _attached.add(ev);
} }
} }
...@@ -68,7 +70,7 @@ public class EventDispatcherImpl implements EventDispatcher { ...@@ -68,7 +70,7 @@ public class EventDispatcherImpl implements EventDispatcher {
if (args == null) { if (args == null) {
args = "[null value]"; args = "[null value]";
} }
_log.debug(this.hashCode() + ": got notification [" + eventName + "] = [" + args + "]"); //_log.debug(this.hashCode() + ": got notification [" + eventName + "] = [" + args + "]");
synchronized (_events) { synchronized (_events) {
_events.put(eventName, args); _events.put(eventName, args);
_events.notifyAll(); _events.notifyAll();
...@@ -77,8 +79,8 @@ public class EventDispatcherImpl implements EventDispatcher { ...@@ -77,8 +79,8 @@ public class EventDispatcherImpl implements EventDispatcher {
EventDispatcher e; EventDispatcher e;
while (it.hasNext()) { while (it.hasNext()) {
e = (EventDispatcher) it.next(); e = (EventDispatcher) it.next();
_log.debug(this.hashCode() + ": notifying attached EventDispatcher " + e.hashCode() + ": [" //_log.debug(this.hashCode() + ": notifying attached EventDispatcher " + e.hashCode() + ": ["
+ eventName + "] = [" + args + "]"); // + eventName + "] = [" + args + "]");
e.notifyEvent(eventName, args); e.notifyEvent(eventName, args);
} }
} }
...@@ -112,7 +114,6 @@ public class EventDispatcherImpl implements EventDispatcher { ...@@ -112,7 +114,6 @@ public class EventDispatcherImpl implements EventDispatcher {
synchronized (_events) { synchronized (_events) {
_events.clear(); _events.clear();
} }
_events = null;
} }
public void unIgnoreEvents() { public void unIgnoreEvents() {
...@@ -123,7 +124,7 @@ public class EventDispatcherImpl implements EventDispatcher { ...@@ -123,7 +124,7 @@ public class EventDispatcherImpl implements EventDispatcher {
if (_ignore) return null; if (_ignore) return null;
Object val; Object val;
_log.debug(this.hashCode() + ": waiting for [" + name + "]"); //_log.debug(this.hashCode() + ": waiting for [" + name + "]");
do { do {
synchronized (_events) { synchronized (_events) {
if (_events.containsKey(name)) { if (_events.containsKey(name)) {
...@@ -139,4 +140,4 @@ public class EventDispatcherImpl implements EventDispatcher { ...@@ -139,4 +140,4 @@ public class EventDispatcherImpl implements EventDispatcher {
return val; return val;
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment