Skip to content

Commit 9ffdf05

Browse files
committed
Explicit javadoc note on publishEvent hand-off semantics
See gh-21025
1 parent 18bfa6b commit 9ffdf05

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Diff for: spring-context/src/main/java/org/springframework/context/ApplicationEventPublisher.java

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,14 +18,16 @@
1818

1919
/**
2020
* Interface that encapsulates event publication functionality.
21-
* Serves as super-interface for {@link ApplicationContext}.
21+
*
22+
* <p>Serves as a super-interface for {@link ApplicationContext}.
2223
*
2324
* @author Juergen Hoeller
2425
* @author Stephane Nicoll
2526
* @since 1.1.1
2627
* @see ApplicationContext
2728
* @see ApplicationEventPublisherAware
2829
* @see org.springframework.context.ApplicationEvent
30+
* @see org.springframework.context.event.ApplicationEventMulticaster
2931
* @see org.springframework.context.event.EventPublicationInterceptor
3032
*/
3133
@FunctionalInterface
@@ -34,9 +36,16 @@ public interface ApplicationEventPublisher {
3436
/**
3537
* Notify all <strong>matching</strong> listeners registered with this
3638
* application of an application event. Events may be framework events
37-
* (such as RequestHandledEvent) or application-specific events.
39+
* (such as ContextRefreshedEvent) or application-specific events.
40+
* <p>Such an event publication step is effectively a hand-off to the
41+
* multicaster and does not imply synchronous/asynchronous execution
42+
* or even immediate execution at all. Event listeners are encouraged
43+
* to be as efficient as possible, individually using asynchronous
44+
* execution for longer-running and potentially blocking operations.
3845
* @param event the event to publish
39-
* @see org.springframework.web.context.support.RequestHandledEvent
46+
* @see #publishEvent(Object)
47+
* @see org.springframework.context.event.ContextRefreshedEvent
48+
* @see org.springframework.context.event.ContextClosedEvent
4049
*/
4150
default void publishEvent(ApplicationEvent event) {
4251
publishEvent((Object) event);
@@ -47,8 +56,14 @@ default void publishEvent(ApplicationEvent event) {
4756
* application of an event.
4857
* <p>If the specified {@code event} is not an {@link ApplicationEvent},
4958
* it is wrapped in a {@link PayloadApplicationEvent}.
59+
* <p>Such an event publication step is effectively a hand-off to the
60+
* multicaster and does not imply synchronous/asynchronous execution
61+
* or even immediate execution at all. Event listeners are encouraged
62+
* to be as efficient as possible, individually using asynchronous
63+
* execution for longer-running and potentially blocking operations.
5064
* @param event the event to publish
5165
* @since 4.2
66+
* @see #publishEvent(ApplicationEvent)
5267
* @see PayloadApplicationEvent
5368
*/
5469
void publishEvent(Object event);

0 commit comments

Comments
 (0)