tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.trivial.impl; |
| 2 | |
| 3 | import org.onlab.onos.event.DefaultEventSinkRegistry; |
| 4 | import org.onlab.onos.event.Event; |
| 5 | import org.onlab.onos.event.EventDeliveryService; |
| 6 | import org.onlab.onos.event.EventSink; |
| 7 | |
| 8 | import static com.google.common.base.Preconditions.checkState; |
| 9 | |
| 10 | /** |
| 11 | * Implements event delivery system that delivers events synchronously, or |
| 12 | * in-line with the post method invocation. |
| 13 | */ |
| 14 | public class TestEventDispatcher extends DefaultEventSinkRegistry |
| 15 | implements EventDeliveryService { |
| 16 | |
| 17 | @Override |
| 18 | public void post(Event event) { |
| 19 | EventSink sink = getSink(event.getClass()); |
| 20 | checkState(sink != null, "No sink for event %s", event); |
| 21 | sink.process(event); |
| 22 | } |
| 23 | |
| 24 | } |