mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-17 20:59:29 +00:00
Event driven architecture refactored.
1. Renamed Message to Event and Event to AbstractEvent 2. Generified Event and Handler 3. Updated EventDispatcher to make unsafe configuration impossible 4. Updated UML diagram accordingly
This commit is contained in:
+4
-4
@@ -22,7 +22,6 @@
|
||||
*/
|
||||
package com.iluwatar.eda.handler;
|
||||
|
||||
import com.iluwatar.eda.event.Event;
|
||||
import com.iluwatar.eda.event.UserCreatedEvent;
|
||||
import com.iluwatar.eda.framework.Handler;
|
||||
|
||||
@@ -32,9 +31,10 @@ import com.iluwatar.eda.framework.Handler;
|
||||
public class UserCreatedEventHandler implements Handler<UserCreatedEvent> {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event message) {
|
||||
public void onEvent(UserCreatedEvent event) {
|
||||
|
||||
UserCreatedEvent userCreatedEvent = (UserCreatedEvent) message;
|
||||
System.out.printf("User with %s has been Created!", userCreatedEvent.getUser().getUsername());
|
||||
System.out.println(String.format(
|
||||
"User '%s' has been Created!", event.getUser().getUsername()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user