mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-17 08:59:12 +00:00
#113 Event Driven Architecture
- refactored and moved around some classes
This commit is contained in:
+9
-4
@@ -1,18 +1,23 @@
|
||||
package com.iluwatar.eda.advanced;
|
||||
|
||||
import com.iluwatar.eda.advanced.events.Event;
|
||||
import com.iluwatar.eda.advanced.framework.Channel;
|
||||
import com.iluwatar.eda.advanced.framework.DynamicRouter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EventDispatcher implements DynamicRouter<Event> {
|
||||
private Map<Class<? extends Event>, Handler> handlers;
|
||||
|
||||
private Map<Class<? extends Event>, Channel> handlers;
|
||||
|
||||
public EventDispatcher() {
|
||||
handlers = new HashMap<Class<? extends Event>, Handler>();
|
||||
handlers = new HashMap<Class<? extends Event>, Channel>();
|
||||
}
|
||||
|
||||
public void registerChannel(Class<? extends Event> contentType,
|
||||
Channel<? extends Event> channel) {
|
||||
handlers.put(contentType, (Handler)channel);
|
||||
Channel channel) {
|
||||
handlers.put(contentType, channel);
|
||||
}
|
||||
|
||||
public void dispatch(Event content) {
|
||||
|
||||
Reference in New Issue
Block a user