Skip to content

Commit 46c7861

Browse files
committed
Replace "blacklist" with alternative words
See gh-25262
1 parent 0a14ea6 commit 46c7861

File tree

1 file changed

+48
-47
lines changed

1 file changed

+48
-47
lines changed

src/docs/asciidoc/core/core-beans.adoc

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10562,12 +10562,12 @@ simple class that extends Spring's `ApplicationEvent` base class:
1056210562
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
1056310563
.Java
1056410564
----
10565-
public class BlackListEvent extends ApplicationEvent {
10565+
public class BlockedListEvent extends ApplicationEvent {
1056610566
1056710567
private final String address;
1056810568
private final String content;
1056910569
10570-
public BlackListEvent(Object source, String address, String content) {
10570+
public BlockedListEvent(Object source, String address, String content) {
1057110571
super(source);
1057210572
this.address = address;
1057310573
this.content = content;
@@ -10579,7 +10579,7 @@ simple class that extends Spring's `ApplicationEvent` base class:
1057910579
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1058010580
.Kotlin
1058110581
----
10582-
class BlackListEvent(source: Any,
10582+
class BlockedListEvent(source: Any,
1058310583
val address: String,
1058410584
val content: String) : ApplicationEvent(source)
1058510585
----
@@ -10594,20 +10594,20 @@ example shows such a class:
1059410594
----
1059510595
public class EmailService implements ApplicationEventPublisherAware {
1059610596
10597-
private List<String> blackList;
10597+
private List<String> blockedList;
1059810598
private ApplicationEventPublisher publisher;
1059910599
10600-
public void setBlackList(List<String> blackList) {
10601-
this.blackList = blackList;
10600+
public void setBlockedList(List<String> blockedList) {
10601+
this.blockedList = blockedList;
1060210602
}
1060310603
1060410604
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
1060510605
this.publisher = publisher;
1060610606
}
1060710607
1060810608
public void sendEmail(String address, String content) {
10609-
if (blackList.contains(address)) {
10610-
publisher.publishEvent(new BlackListEvent(this, address, content));
10609+
if (blockedList.contains(address)) {
10610+
publisher.publishEvent(new BlockedListEvent(this, address, content));
1061110611
return;
1061210612
}
1061310613
// send email...
@@ -10619,20 +10619,20 @@ example shows such a class:
1061910619
----
1062010620
class EmailService : ApplicationEventPublisherAware {
1062110621
10622-
private lateinit var blackList: List<String>
10622+
private lateinit var blockedList: List<String>
1062310623
private lateinit var publisher: ApplicationEventPublisher
1062410624
10625-
fun setBlackList(blackList: List<String>) {
10626-
this.blackList = blackList
10625+
fun setBlockedList(blockedList: List<String>) {
10626+
this.blockedList = blockedList
1062710627
}
1062810628
1062910629
override fun setApplicationEventPublisher(publisher: ApplicationEventPublisher) {
1063010630
this.publisher = publisher
1063110631
}
1063210632
1063310633
fun sendEmail(address: String, content: String) {
10634-
if (blackList!!.contains(address)) {
10635-
publisher!!.publishEvent(BlackListEvent(this, address, content))
10634+
if (blockedList!!.contains(address)) {
10635+
publisher!!.publishEvent(BlockedListEvent(this, address, content))
1063610636
return
1063710637
}
1063810638
// send email...
@@ -10653,41 +10653,42 @@ shows such a class:
1065310653
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
1065410654
.Java
1065510655
----
10656-
public class BlackListNotifier implements ApplicationListener<BlackListEvent> {
10656+
public class BlockedListNotifier implements ApplicationListener<BlockedListEvent> {
1065710657
1065810658
private String notificationAddress;
1065910659
1066010660
public void setNotificationAddress(String notificationAddress) {
1066110661
this.notificationAddress = notificationAddress;
1066210662
}
1066310663
10664-
public void onApplicationEvent(BlackListEvent event) {
10664+
public void onApplicationEvent(BlockedListEvent event) {
1066510665
// notify appropriate parties via notificationAddress...
1066610666
}
1066710667
}
1066810668
----
1066910669
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1067010670
.Kotlin
1067110671
----
10672-
class BlackListNotifier : ApplicationListener<BlackListEvent> {
10672+
class BlockedListNotifier : ApplicationListener<BlockedListEvent> {
1067310673
1067410674
lateinit var notificationAddres: String
1067510675
10676-
override fun onApplicationEvent(event: BlackListEvent) {
10676+
override fun onApplicationEvent(event: BlockedListEvent) {
1067710677
// notify appropriate parties via notificationAddress...
1067810678
}
1067910679
}
1068010680
----
1068110681

1068210682
Notice that `ApplicationListener` is generically parameterized with the type of your
10683-
custom event (`BlackListEvent` in the preceding example). This means that the `onApplicationEvent()` method can
10684-
remain type-safe, avoiding any need for downcasting. You can register as many event
10685-
listeners as you wish, but note that, by default, event listeners receive events
10686-
synchronously. This means that the `publishEvent()` method blocks until all listeners have
10687-
finished processing the event. One advantage of this synchronous and single-threaded
10688-
approach is that, when a listener receives an event, it operates inside the transaction
10689-
context of the publisher if a transaction context is available. If another strategy for
10690-
event publication becomes necessary, see the javadoc for Spring's
10683+
custom event (`BlockedListEvent` in the preceding example). This means that the
10684+
`onApplicationEvent()` method can remain type-safe, avoiding any need for downcasting.
10685+
You can register as many event listeners as you wish, but note that, by default, event
10686+
listeners receive events synchronously. This means that the `publishEvent()` method
10687+
blocks until all listeners have finished processing the event. One advantage of this
10688+
synchronous and single-threaded approach is that, when a listener receives an event, it
10689+
operates inside the transaction context of the publisher if a transaction context is
10690+
available. If another strategy for event publication becomes necessary, see the javadoc
10691+
for Spring's
1069110692
{api-spring-framework}/context/event/ApplicationEventMulticaster.html[`ApplicationEventMulticaster`] interface
1069210693
and {api-spring-framework}/context/event/SimpleApplicationEventMulticaster.html[`SimpleApplicationEventMulticaster`]
1069310694
implementation for configuration options.
@@ -10698,7 +10699,7 @@ the classes above:
1069810699
[source,xml,indent=0,subs="verbatim,quotes"]
1069910700
----
1070010701
<bean id="emailService" class="example.EmailService">
10701-
<property name="blackList">
10702+
<property name="blockedList">
1070210703
<list>
1070310704
<value>[email protected]</value>
1070410705
<value>[email protected]</value>
@@ -10707,15 +10708,15 @@ the classes above:
1070710708
</property>
1070810709
</bean>
1070910710
10710-
<bean id="blackListNotifier" class="example.BlackListNotifier">
10711-
<property name="notificationAddress" value="blacklist@example.org"/>
10711+
<bean id="blockedListNotifier" class="example.BlockedListNotifier">
10712+
<property name="notificationAddress" value="blockedlist@example.org"/>
1071210713
</bean>
1071310714
----
1071410715

1071510716
Putting it all together, when the `sendEmail()` method of the `emailService` bean is
10716-
called, if there are any email messages that should be blacklisted, a custom event of type
10717-
`BlackListEvent` is published. The `blackListNotifier` bean is registered as an
10718-
`ApplicationListener` and receives the `BlackListEvent`, at which point it can
10717+
called, if there are any email messages that should be blocked, a custom event of type
10718+
`BlockedListEvent` is published. The `blockedListNotifier` bean is registered as an
10719+
`ApplicationListener` and receives the `BlockedListEvent`, at which point it can
1071910720
notify appropriate parties.
1072010721

1072110722
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.
1073110732
==== Annotation-based Event Listeners
1073210733

1073310734
As of Spring 4.2, you can register an event listener on any public method of a managed
10734-
bean by using the `@EventListener` annotation. The `BlackListNotifier` can be rewritten as
10735+
bean by using the `@EventListener` annotation. The `BlockedListNotifier` can be rewritten as
1073510736
follows:
1073610737

1073710738
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
1073810739
.Java
1073910740
----
10740-
public class BlackListNotifier {
10741+
public class BlockedListNotifier {
1074110742
1074210743
private String notificationAddress;
1074310744
@@ -10746,20 +10747,20 @@ follows:
1074610747
}
1074710748
1074810749
@EventListener
10749-
public void processBlackListEvent(BlackListEvent event) {
10750+
public void processBlockedListEvent(BlockedListEvent event) {
1075010751
// notify appropriate parties via notificationAddress...
1075110752
}
1075210753
}
1075310754
----
1075410755
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1075510756
.Kotlin
1075610757
----
10757-
class BlackListNotifier {
10758+
class BlockedListNotifier {
1075810759
1075910760
lateinit var notificationAddress: String
1076010761
1076110762
@EventListener
10762-
fun processBlackListEvent(event: BlackListEvent) {
10763+
fun processBlockedListEvent(event: BlockedListEvent) {
1076310764
// notify appropriate parties via notificationAddress...
1076410765
}
1076510766
}
@@ -10802,15 +10803,15 @@ The following example shows how our notifier can be rewritten to be invoked only
1080210803
.Java
1080310804
----
1080410805
@EventListener(condition = "#blEvent.content == 'my-event'")
10805-
public void processBlackListEvent(BlackListEvent blEvent) {
10806+
public void processBlockedListEvent(BlockedListEvent blockedListEvent) {
1080610807
// notify appropriate parties via notificationAddress...
1080710808
}
1080810809
----
1080910810
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1081010811
.Kotlin
1081110812
----
1081210813
@EventListener(condition = "#blEvent.content == 'my-event'")
10813-
fun processBlackListEvent(blEvent: BlackListEvent) {
10814+
fun processBlockedListEvent(blockedListEvent: BlockedListEvent) {
1081410815
// notify appropriate parties via notificationAddress...
1081510816
}
1081610817
----
@@ -10852,7 +10853,7 @@ method signature to return the event that should be published, as the following
1085210853
.Java
1085310854
----
1085410855
@EventListener
10855-
public ListUpdateEvent handleBlackListEvent(BlackListEvent event) {
10856+
public ListUpdateEvent handleBlockedListEvent(BlockedListEvent event) {
1085610857
// notify appropriate parties via notificationAddress and
1085710858
// then publish a ListUpdateEvent...
1085810859
}
@@ -10861,7 +10862,7 @@ method signature to return the event that should be published, as the following
1086110862
.Kotlin
1086210863
----
1086310864
@EventListener
10864-
fun handleBlackListEvent(event: BlackListEvent): ListUpdateEvent {
10865+
fun handleBlockedListEvent(event: BlockedListEvent): ListUpdateEvent {
1086510866
// notify appropriate parties via notificationAddress and
1086610867
// then publish a ListUpdateEvent...
1086710868
}
@@ -10870,7 +10871,7 @@ method signature to return the event that should be published, as the following
1087010871
NOTE: This feature is not supported for
1087110872
<<context-functionality-events-async, asynchronous listeners>>.
1087210873

10873-
This new method publishes a new `ListUpdateEvent` for every `BlackListEvent` handled by the
10874+
This new method publishes a new `ListUpdateEvent` for every `BlockedListEvent` handled by the
1087410875
method above. If you need to publish several events, you can return a `Collection` of events
1087510876
instead.
1087610877

@@ -10887,17 +10888,17 @@ The following example shows how to do so:
1088710888
----
1088810889
@EventListener
1088910890
@Async
10890-
public void processBlackListEvent(BlackListEvent event) {
10891-
// BlackListEvent is processed in a separate thread
10891+
public void processBlockedListEvent(BlockedListEvent event) {
10892+
// BlockedListEvent is processed in a separate thread
1089210893
}
1089310894
----
1089410895
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1089510896
.Kotlin
1089610897
----
1089710898
@EventListener
1089810899
@Async
10899-
fun processBlackListEvent(event: BlackListEvent) {
10900-
// BlackListEvent is processed in a separate thread
10900+
fun processBlockedListEvent(event: BlockedListEvent) {
10901+
// BlockedListEvent is processed in a separate thread
1090110902
}
1090210903
----
1090310904

@@ -10922,7 +10923,7 @@ annotation to the method declaration, as the following example shows:
1092210923
----
1092310924
@EventListener
1092410925
@Order(42)
10925-
public void processBlackListEvent(BlackListEvent event) {
10926+
public void processBlockedListEvent(BlockedListEvent event) {
1092610927
// notify appropriate parties via notificationAddress...
1092710928
}
1092810929
----
@@ -10931,7 +10932,7 @@ annotation to the method declaration, as the following example shows:
1093110932
----
1093210933
@EventListener
1093310934
@Order(42)
10934-
fun processBlackListEvent(event: BlackListEvent) {
10935+
fun processBlockedListEvent(event: BlockedListEvent) {
1093510936
// notify appropriate parties via notificationAddress...
1093610937
}
1093710938
----

0 commit comments

Comments
 (0)