mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 16:58:56 +00:00
@@ -7,22 +7,21 @@ import com.iluwatar.eda.handler.UserCreatedEventHandler;
|
||||
import com.iluwatar.eda.handler.UserUpdatedEventHandler;
|
||||
|
||||
/**
|
||||
* An event-driven architecture (EDA) is a framework that orchestrates behavior around the production,
|
||||
* detection and consumption of events as well as the responses they evoke.
|
||||
* An event is any identifiable occurrence that has significance for system hardware or software.
|
||||
* <p/>
|
||||
* The example below we uses an {@link EventDispatcher} to link/register {@link Event} objects to
|
||||
* their respective handlers Once an {@link Event} is dispatched,
|
||||
* it's respective handler is invoked and the {@link Event} is handled accordingly
|
||||
* An event-driven architecture (EDA) is a framework that orchestrates behavior around the
|
||||
* production, detection and consumption of events as well as the responses they evoke. An event is
|
||||
* any identifiable occurrence that has significance for system hardware or software. <p/> The
|
||||
* example below we uses an {@link EventDispatcher} to link/register {@link Event} objects to their
|
||||
* respective handlers Once an {@link Event} is dispatched, it's respective handler is invoked and
|
||||
* the {@link Event} is handled accordingly
|
||||
*/
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
EventDispatcher dispatcher = new EventDispatcher();
|
||||
dispatcher.registerChannel(UserCreatedEvent.class, new UserCreatedEventHandler());
|
||||
dispatcher.registerChannel(UserUpdatedEvent.class, new UserUpdatedEventHandler());
|
||||
dispatcher.dispatch(new UserCreatedEvent());
|
||||
dispatcher.dispatch(new UserUpdatedEvent());
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
EventDispatcher dispatcher = new EventDispatcher();
|
||||
dispatcher.registerChannel(UserCreatedEvent.class, new UserCreatedEventHandler());
|
||||
dispatcher.registerChannel(UserUpdatedEvent.class, new UserUpdatedEventHandler());
|
||||
dispatcher.dispatch(new UserCreatedEvent());
|
||||
dispatcher.dispatch(new UserUpdatedEvent());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user