This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ralf-ueberfuhr-ars/feature/events
Add customer event logger
- Loading branch information
Showing
8 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...rovider/src/main/java/de/sample/schulung/accounts/domain/events/CustomerCreatedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.sample.schulung.accounts.domain.events; | ||
|
||
import de.sample.schulung.accounts.domain.Customer; | ||
|
||
public record CustomerCreatedEvent( | ||
Customer customer | ||
) { | ||
} |
8 changes: 8 additions & 0 deletions
8
...rovider/src/main/java/de/sample/schulung/accounts/domain/events/CustomerDeletedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.sample.schulung.accounts.domain.events; | ||
|
||
import java.util.UUID; | ||
|
||
public record CustomerDeletedEvent( | ||
UUID uuid | ||
) { | ||
} |
8 changes: 8 additions & 0 deletions
8
...ovider/src/main/java/de/sample/schulung/accounts/domain/events/CustomerReplacedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.sample.schulung.accounts.domain.events; | ||
|
||
import de.sample.schulung.accounts.domain.Customer; | ||
|
||
public record CustomerReplacedEvent( | ||
Customer customer | ||
) { | ||
} |
15 changes: 15 additions & 0 deletions
15
...rovider/src/main/java/de/sample/schulung/accounts/domain/logging/CustomerEventLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.sample.schulung.accounts.domain.logging; | ||
|
||
import de.sample.schulung.accounts.domain.Customer; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Slf4j | ||
public class CustomerEventLogger { | ||
|
||
public void logCustomerCreated(Customer customer) { | ||
log.info("Customer created with UUID {}", customer.getUuid()); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...vider/src/main/java/de/sample/schulung/accounts/domain/logging/CustomerEventObserver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package de.sample.schulung.accounts.domain.logging; | ||
|
||
import de.sample.schulung.accounts.domain.events.CustomerCreatedEvent; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class CustomerEventObserver { | ||
|
||
private final CustomerEventLogger customerEventLogger; | ||
|
||
@EventListener | ||
public void handle(CustomerCreatedEvent event) { | ||
customerEventLogger.logCustomerCreated(event.customer()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters