@ -10562,12 +10562,12 @@ simple class that extends Spring's `ApplicationEvent` base class:
@@ -10562,12 +10562,12 @@ simple class that extends Spring's `ApplicationEvent` base class:
public class BlackListEvent extends ApplicationEvent {
public class BlockedListEvent extends ApplicationEvent {
private final String address;
private final String content;
public BlackListEvent(Object source, String address, String content) {
public BlockedListEvent(Object source, String address, String content) {
super(source);
this.address = address;
this.content = content;
@ -10579,7 +10579,7 @@ simple class that extends Spring's `ApplicationEvent` base class:
@@ -10579,7 +10579,7 @@ simple class that extends Spring's `ApplicationEvent` base class:
Putting it all together, when the `sendEmail()` method of the `emailService` bean is
called, if there are any email messages that should be blacklisted, a custom event of type
`BlackListEvent` is published. The `blackListNotifier` bean is registered as an
`ApplicationListener` and receives the `BlackListEvent`, at which point it can
called, if there are any email messages that should be blocked, a custom event of type
`BlockedListEvent` is published. The `blockedListNotifier` bean is registered as an
`ApplicationListener` and receives the `BlockedListEvent`, at which point it can
notify appropriate parties.
NOTE: Spring's eventing mechanism is designed for simple communication between Spring beans
@ -10731,13 +10732,13 @@ architectures that build upon the well-known Spring programming model.
@@ -10731,13 +10732,13 @@ architectures that build upon the well-known Spring programming model.
==== Annotation-based Event Listeners
As of Spring 4.2, you can register an event listener on any public method of a managed
bean by using the `@EventListener` annotation. The `BlackListNotifier` can be rewritten as
bean by using the `@EventListener` annotation. The `BlockedListNotifier` can be rewritten as
fun processBlackListEvent(event: BlackListEvent) {
fun processBlockedListEvent(event: BlockedListEvent) {
// notify appropriate parties via notificationAddress...
}
}
@ -10802,7 +10803,7 @@ The following example shows how our notifier can be rewritten to be invoked only
@@ -10802,7 +10803,7 @@ The following example shows how our notifier can be rewritten to be invoked only
public void processBlackListEvent(BlackListEvent blEvent) {
public void processBlockedListEvent(BlockedListEvent blockedListEvent) {
// notify appropriate parties via notificationAddress...
}
----
@ -10810,7 +10811,7 @@ The following example shows how our notifier can be rewritten to be invoked only
@@ -10810,7 +10811,7 @@ The following example shows how our notifier can be rewritten to be invoked only
fun processBlackListEvent(blEvent: BlackListEvent) {
fun processBlockedListEvent(blockedListEvent: BlockedListEvent) {
// notify appropriate parties via notificationAddress...
}
----
@ -10852,7 +10853,7 @@ method signature to return the event that should be published, as the following
@@ -10852,7 +10853,7 @@ method signature to return the event that should be published, as the following
.Java
----
@EventListener
public ListUpdateEvent handleBlackListEvent(BlackListEvent event) {
public ListUpdateEvent handleBlockedListEvent(BlockedListEvent event) {
// notify appropriate parties via notificationAddress and
// then publish a ListUpdateEvent...
}
@ -10861,7 +10862,7 @@ method signature to return the event that should be published, as the following
@@ -10861,7 +10862,7 @@ method signature to return the event that should be published, as the following
.Kotlin
----
@EventListener
fun handleBlackListEvent(event: BlackListEvent): ListUpdateEvent {
fun handleBlockedListEvent(event: BlockedListEvent): ListUpdateEvent {
// notify appropriate parties via notificationAddress and
// then publish a ListUpdateEvent...
}
@ -10870,7 +10871,7 @@ method signature to return the event that should be published, as the following
@@ -10870,7 +10871,7 @@ method signature to return the event that should be published, as the following
@ -10896,8 +10897,8 @@ The following example shows how to do so:
@@ -10896,8 +10897,8 @@ The following example shows how to do so:
----
@EventListener
@Async
fun processBlackListEvent(event: BlackListEvent) {
// BlackListEvent is processed in a separate thread
fun processBlockedListEvent(event: BlockedListEvent) {
// BlockedListEvent is processed in a separate thread
}
----
@ -10922,7 +10923,7 @@ annotation to the method declaration, as the following example shows:
@@ -10922,7 +10923,7 @@ annotation to the method declaration, as the following example shows:
----
@EventListener
@Order(42)
public void processBlackListEvent(BlackListEvent event) {
public void processBlockedListEvent(BlockedListEvent event) {
// notify appropriate parties via notificationAddress...
}
----
@ -10931,7 +10932,7 @@ annotation to the method declaration, as the following example shows:
@@ -10931,7 +10932,7 @@ annotation to the method declaration, as the following example shows:
----
@EventListener
@Order(42)
fun processBlackListEvent(event: BlackListEvent) {
fun processBlockedListEvent(event: BlockedListEvent) {
// notify appropriate parties via notificationAddress...