mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-24 23:36:25 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -61,5 +61,4 @@ public class App {
|
||||
dispatcher.dispatch(new UserCreatedEvent(user));
|
||||
dispatcher.dispatch(new UserUpdatedEvent(user));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,12 @@ import com.iluwatar.eda.framework.EventDispatcher;
|
||||
/**
|
||||
* The {@link AbstractEvent} class serves as a base class for defining custom events happening with
|
||||
* your system. In this example we have two types of events defined.
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link UserCreatedEvent} - used when a user is created</li>
|
||||
* <li>{@link UserUpdatedEvent} - used when a user is updated</li>
|
||||
* <li>{@link UserCreatedEvent} - used when a user is created
|
||||
* <li>{@link UserUpdatedEvent} - used when a user is updated
|
||||
* </ul>
|
||||
*
|
||||
* Events can be distinguished using the {@link #getType() getType} method.
|
||||
*/
|
||||
public abstract class AbstractEvent implements Event {
|
||||
@@ -47,4 +49,4 @@ public abstract class AbstractEvent implements Event {
|
||||
public Class<? extends Event> getType() {
|
||||
return getClass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -29,9 +29,9 @@ import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* The {@link UserCreatedEvent} should be dispatched whenever a user has been created.
|
||||
* This class can be extended to contain details about the user has been created.
|
||||
* In this example, the entire {@link User} object is passed on as data with the event.
|
||||
* The {@link UserCreatedEvent} should be dispatched whenever a user has been created. This class
|
||||
* can be extended to contain details about the user has been created. In this example, the entire
|
||||
* {@link User} object is passed on as data with the event.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
|
||||
+3
-3
@@ -29,9 +29,9 @@ import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* The {@link UserUpdatedEvent} should be dispatched whenever a user has been updated.
|
||||
* This class can be extended to contain details about the user has been updated.
|
||||
* In this example, the entire {@link User} object is passed on as data with the event.
|
||||
* The {@link UserUpdatedEvent} should be dispatched whenever a user has been updated. This class
|
||||
* can be extended to contain details about the user has been updated. In this example, the entire
|
||||
* {@link User} object is passed on as data with the event.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
|
||||
+2
-6
@@ -43,12 +43,9 @@ public class EventDispatcher {
|
||||
* Links an {@link Event} to a specific {@link Handler}.
|
||||
*
|
||||
* @param eventType The {@link Event} to be registered
|
||||
* @param handler The {@link Handler} that will be handling the {@link Event}
|
||||
* @param handler The {@link Handler} that will be handling the {@link Event}
|
||||
*/
|
||||
public <E extends Event> void registerHandler(
|
||||
Class<E> eventType,
|
||||
Handler<E> handler
|
||||
) {
|
||||
public <E extends Event> void registerHandler(Class<E> eventType, Handler<E> handler) {
|
||||
handlers.put(eventType, handler);
|
||||
}
|
||||
|
||||
@@ -64,5 +61,4 @@ public class EventDispatcher {
|
||||
handler.onEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-4
@@ -28,9 +28,7 @@ import com.iluwatar.eda.event.UserCreatedEvent;
|
||||
import com.iluwatar.eda.framework.Handler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Handles the {@link UserCreatedEvent} message.
|
||||
*/
|
||||
/** Handles the {@link UserCreatedEvent} message. */
|
||||
@Slf4j
|
||||
public class UserCreatedEventHandler implements Handler<UserCreatedEvent> {
|
||||
|
||||
@@ -38,5 +36,4 @@ public class UserCreatedEventHandler implements Handler<UserCreatedEvent> {
|
||||
public void onEvent(UserCreatedEvent event) {
|
||||
LOGGER.info("User '{}' has been Created!", event.getUser().username());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -28,9 +28,7 @@ import com.iluwatar.eda.event.UserUpdatedEvent;
|
||||
import com.iluwatar.eda.framework.Handler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Handles the {@link UserUpdatedEvent} message.
|
||||
*/
|
||||
/** Handles the {@link UserUpdatedEvent} message. */
|
||||
@Slf4j
|
||||
public class UserUpdatedEventHandler implements Handler<UserUpdatedEvent> {
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@ package com.iluwatar.eda.model;
|
||||
|
||||
import com.iluwatar.eda.event.UserCreatedEvent;
|
||||
import com.iluwatar.eda.event.UserUpdatedEvent;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* This {@link User} class is a basic pojo used to demonstrate user data sent along with the {@link
|
||||
|
||||
Reference in New Issue
Block a user