org.springframework.context.event

Class AbstractApplicationEventMulticaster

  • java.lang.Object
    • org.springframework.context.event.AbstractApplicationEventMulticaster
    • Constructor Detail

      • AbstractApplicationEventMulticaster

        public AbstractApplicationEventMulticaster()
    • Method Detail

      • removeAllListeners

        public void removeAllListeners()
        Description copied from interface: ApplicationEventMulticaster
        Remove all listeners registered with this multicaster.

        After a remove call, the multicaster will perform no action on event notification until new listeners are being registered.

        Specified by:
        removeAllListeners in interface ApplicationEventMulticaster
      • getApplicationListeners

        protected java.util.Collection<ApplicationListener<?>> getApplicationListeners()
        Return a Collection containing all ApplicationListeners.
        Returns:
        a Collection of ApplicationListeners
        See Also:
        ApplicationListener
      • getApplicationListeners

        protected java.util.Collection<ApplicationListener<?>> getApplicationListeners(ApplicationEvent event,
                                                                                       ResolvableType eventType)
        Return a Collection of ApplicationListeners matching the given event type. Non-matching listeners get excluded early.
        Parameters:
        event - the event to be propagated. Allows for excluding non-matching listeners early, based on cached matching information.
        eventType - the event type
        Returns:
        a Collection of ApplicationListeners
        See Also:
        ApplicationListener
      • supportsEvent

        protected boolean supportsEvent(java.lang.Class<?> listenerType,
                                        ResolvableType eventType)
        Filter a listener early through checking its generically declared event type before trying to instantiate it.

        If this method returns true for a given listener as a first pass, the listener instance will get retrieved and fully evaluated through a supportsEvent(ApplicationListener,ResolvableType, Class) call afterwards.

        Parameters:
        listenerType - the listener's type as determined by the BeanFactory
        eventType - the event type to check
        Returns:
        whether the given listener should be included in the candidates for the given event type
      • supportsEvent

        protected boolean supportsEvent(ApplicationListener<?> listener,
                                        ResolvableType eventType,
                                        @Nullable
                                        java.lang.Class<?> sourceType)
        Determine whether the given listener supports the given event.

        The default implementation detects the SmartApplicationListener and GenericApplicationListener interfaces. In case of a standard ApplicationListener, a GenericApplicationListenerAdapter will be used to introspect the generically declared type of the target listener.

        Parameters:
        listener - the target listener to check
        eventType - the event type to check against
        sourceType - the source type to check against
        Returns:
        whether the given listener should be included in the candidates for the given event type