ApplicationEventMulticaster interface,
providing the basic listener registration facility.
Doesn't permit multiple instances of the same listener by default, as it keeps listeners in a linked Set. The collection class used to hold ApplicationListener objects can be overridden through the "collectionClass" bean property.
Implementing ApplicationEventMulticaster's actual multicastEvent method
is left to subclasses. SimpleApplicationEventMulticaster simply multicasts
all events to all registered listeners, invoking them in the calling thread by
default. Alternative implementations could be more sophisticated in those respects.
getApplicationListeners(ApplicationEvent, ResolvableType), SimpleApplicationEventMulticaster
| Modifier and Type | Class and Description |
|---|---|
| private class | AbstractApplicationEventMulticaster.
Helper class that encapsulates a specific set of target listeners, allowing for efficient retrieval of pre-filtered listeners. |
| private class | AbstractApplicationEventMulticaster.
Helper class that encapsulates a general set of target listeners. |
| private static class | AbstractApplicationEventMulticaster.
Cache key for ListenerRetrievers, based on event type and source type. |
| Modifier and Type | Field and Description |
|---|---|
| private ClassLoader | |
| private ConfigurableBeanFactory | |
| private final AbstractApplicationEventMulticaster. | |
| pack-priv final Map |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addApplicationListener(ApplicationListener<?>
the listener to add listener)Implements org. Add a listener to be notified of all events. |
| public void | addApplicationListenerBean(String
the name of the listener bean to add listenerBeanName)Implements org. Add a listener bean to be notified of all events. |
| protected Collection | Returns: a Collection of ApplicationListenersReturn a Collection containing all ApplicationListeners. |
| protected Collection | Returns: a Collection of ApplicationListenersthe event to be propagated. Allows for excluding
non-matching listeners early, based on cached matching information. event, ResolvableType the event type eventType)Return a Collection of ApplicationListeners matching the given event type. |
| private ConfigurableBeanFactory | |
| public void | removeAllListeners()
Implements org. Remove all listeners registered with this multicaster. |
| public void | removeApplicationListener(ApplicationListener<?>
the listener to remove listener)Implements org. Remove a listener from the notification list. |
| public void | removeApplicationListenerBean(String
the name of the listener bean to remove listenerBeanName)Implements org. Remove a listener bean from the notification list. |
| public void | removeApplicationListenerBeans(Predicate<String>
the predicate to identify listener bean names to remove predicate)Implements org. Remove all matching listener beans from the set of registered
listener bean names (referring to bean classes which in turn
implement the |
| public void | removeApplicationListeners(Predicate<ApplicationListener<?>>
the predicate to identify listener instances to remove,
e.g. checking predicate)SmartApplicationListener#getListenerId()Implements org. Remove all matching listeners from the set of registered
|
| private Collection | Returns: the pre-filtered list of application listeners for the given event and source typethe event type eventType, Class<?> the event source type sourceType, AbstractApplicationEventMulticaster.the ListenerRetriever, if supposed to populate one (for caching purposes) retrieverActually retrieve the application listeners for the given event and source type. |
| public void | setBeanClassLoader(ClassLoader
the owning class loader classLoader)Implements org. Callback that supplies the bean |
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Implements org. Callback that supplies the owning factory to a bean instance. |
| private boolean | Returns: whether the given listener should be included in the candidates for the given event typethe BeanFactory that contains the listener beans beanFactory, String the name of the bean in the BeanFactory listenerBeanName, ResolvableType the event type to check eventType)Filter a bean-defined listener early through checking its generically declared event type before trying to instantiate it. |
| protected boolean | Returns: whether the given listener should be included in the candidates for the given event typethe listener's type as determined by the BeanFactory listenerType, ResolvableType the event type to check eventType)Filter a listener early through checking its generically declared event type before trying to instantiate it. |
| protected boolean | Returns: whether the given listener should be included in the candidates for the given event typethe target listener to check listener, ResolvableType the event type to check against eventType, Class<?> the source type to check against sourceType)Determine whether the given listener supports the given event. |
| beanClassLoader | back to summary |
|---|---|
| private ClassLoader beanClassLoader
| |
| beanFactory | back to summary |
|---|---|
| private ConfigurableBeanFactory beanFactory
| |
| defaultRetriever | back to summary |
|---|---|
| private final AbstractApplicationEventMulticaster. | |
| retrieverCache | back to summary |
|---|---|
| pack-priv final Map<AbstractApplicationEventMulticaster. | |
| AbstractApplicationEventMulticaster | back to summary |
|---|---|
| public AbstractApplicationEventMulticaster() | |
| addApplicationListener | back to summary |
|---|---|
| public void addApplicationListener(ApplicationListener<?> listener) Implements org. Doc from org. Add a listener to be notified of all events.
| |
| addApplicationListenerBean | back to summary |
|---|---|
| public void addApplicationListenerBean(String listenerBeanName) Implements org. Doc from org. Add a listener bean to be notified of all events. | |
| getApplicationListeners | back to summary |
|---|---|
| protected Collection Return a Collection containing all ApplicationListeners.
| |
| getApplicationListeners | back to summary |
|---|---|
| protected Collection Return a Collection of ApplicationListeners matching the given event type. Non-matching listeners get excluded early.
| |
| getBeanFactory | back to summary |
|---|---|
| private ConfigurableBeanFactory getBeanFactory() | |
| removeAllListeners | back to summary |
|---|---|
| public void removeAllListeners() Implements org. Doc from org. Remove all listeners registered with this multicaster. After a remove call, the multicaster will perform no action on event notification until new listeners are registered.
| |
| removeApplicationListener | back to summary |
|---|---|
| public void removeApplicationListener(ApplicationListener<?> listener) Implements org. Doc from org. Remove a listener from the notification list.
| |
| removeApplicationListenerBean | back to summary |
|---|---|
| public void removeApplicationListenerBean(String listenerBeanName) Implements org. Doc from org. Remove a listener bean from the notification list. | |
| removeApplicationListenerBeans | back to summary |
|---|---|
| public void removeApplicationListenerBeans(Predicate<String> predicate) Implements org. Doc from org. Remove all matching listener beans from the set of registered
listener bean names (referring to bean classes which in turn
implement the Note This just applies to bean name registrations, not to
programmatically registered | |
| removeApplicationListeners | back to summary |
|---|---|
| public void removeApplicationListeners(Predicate<ApplicationListener<?>> predicate) Implements org. Doc from org. Remove all matching listeners from the set of registered
Note This just applies to instance registrations, not to listeners registered by bean name.
| |
| retrieveApplicationListeners | back to summary |
|---|---|
| private Collection Actually retrieve the application listeners for the given event and source type.
| |
| setBeanClassLoader | back to summary |
|---|---|
| public void setBeanClassLoader(ClassLoader classLoader) Implements org. Doc from org. Callback that supplies the bean Invoked after the population of normal bean properties but
before an initialization callback such as
| |
| setBeanFactory | back to summary |
|---|---|
| public void setBeanFactory(BeanFactory beanFactory) Implements org. Doc from org. Callback that supplies the owning factory to a bean instance. Invoked after the population of normal bean properties
but before an initialization callback such as
| |
| supportsEvent | back to summary |
|---|---|
| private boolean supportsEvent(ConfigurableBeanFactory beanFactory, String listenerBeanName, ResolvableType eventType) Filter a bean-defined listener early through checking its generically declared event type before trying to instantiate it. If this method returns
| |
| supportsEvent | back to summary |
|---|---|
| protected boolean supportsEvent(Class<?> listenerType, ResolvableType eventType) Filter a listener early through checking its generically declared event type before trying to instantiate it. If this method returns
| |
| supportsEvent | back to summary |
|---|---|
| protected boolean supportsEvent(ApplicationListener<?> listener, ResolvableType eventType, Class<?> sourceType) Determine whether the given listener supports the given event. The default implementation detects the
| |
An instance of this helper gets cached per event type and source type.
| Modifier and Type | Field and Description |
|---|---|
| public volatile Set | |
| public volatile Set |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Collection |
| applicationListenerBeans | back to summary |
|---|---|
| public volatile Set<String> applicationListenerBeans
| |
| applicationListeners | back to summary |
|---|---|
| public volatile Set<ApplicationListener<?>> applicationListeners
| |
| CachedListenerRetriever | back to summary |
|---|---|
| private CachedListenerRetriever() | |
| getApplicationListeners | back to summary |
|---|---|
public Collection
| |
| Modifier and Type | Field and Description |
|---|---|
| public final Set | |
| public final Set |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Collection |
| applicationListenerBeans | back to summary |
|---|---|
| public final Set<String> applicationListenerBeans | |
| applicationListeners | back to summary |
|---|---|
| public final Set<ApplicationListener<?>> applicationListeners | |
| DefaultListenerRetriever | back to summary |
|---|---|
| private DefaultListenerRetriever() | |
| getApplicationListeners | back to summary |
|---|---|
| public Collection | |
| Modifier and Type | Field and Description |
|---|---|
| private final ResolvableType | |
| private final Class |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | compareTo(AbstractApplicationEventMulticaster.
the object to be compared. otherImplements java. Compares this object with the specified object for order. |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. Indicates whether some other object is "equal to" this one. |
| public int | |
| public String |
| eventType | back to summary |
|---|---|
| private final ResolvableType eventType | |
| sourceType | back to summary |
|---|---|
| private final Class<?> sourceType
| |
| ListenerCacheKey | back to summary |
|---|---|
| public ListenerCacheKey(ResolvableType eventType, Class<?> sourceType) | |
| compareTo | back to summary |
|---|---|
| public int compareTo(AbstractApplicationEventMulticaster. Implements java. Doc from java. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |