com.interface21.context.support
Class ApplicationEventMulticasterImpl

java.lang.Object
  |
  +--com.interface21.context.support.ApplicationEventMulticasterImpl
All Implemented Interfaces:
ApplicationEventMulticaster, ApplicationListener, java.util.EventListener

public class ApplicationEventMulticasterImpl
extends java.lang.Object
implements ApplicationEventMulticaster

Concrete implementation of ApplicationEventMulticaster Doesn't permit multiple instances of the same listener.
Note that this class doesn't try to do anything clever to ensure thread safety if listeners are added or removed at runtime. A technique such as Copy-on-Write (Lea:137) could be used to ensure this, but the assumption in this version of this framework is that listeners will be added at application configuration time and not added or removed as the application runs.
All listeners are invoked in the calling thread. This allows the danger of a rogue listener blocking the entire application, but adds minimal overhead.
An alternative implementation could be more sophisticated in both these respects.

Author:
Rod Johnson

Constructor Summary
ApplicationEventMulticasterImpl()
          Creates new ApplicationEventMulticasterImpl
 
Method Summary
 void addApplicationListener(ApplicationListener l)
          Add a listener to be notified of all events
 void onApplicationEvent(ApplicationEvent e)
          Handle an application event
 void removeAllListeners()
          Remove all listeners registered with this multicaster.
 void removeApplicationListener(ApplicationListener l)
          Remove a listener in the notification list]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationEventMulticasterImpl

public ApplicationEventMulticasterImpl()
Creates new ApplicationEventMulticasterImpl
Method Detail

addApplicationListener

public void addApplicationListener(ApplicationListener l)
Description copied from interface: ApplicationEventMulticaster
Add a listener to be notified of all events
Specified by:
addApplicationListener in interface ApplicationEventMulticaster
See Also:
ApplicationEventMulticaster.addApplicationListener(ApplicationListener)

removeApplicationListener

public void removeApplicationListener(ApplicationListener l)
Description copied from interface: ApplicationEventMulticaster
Remove a listener in the notification list]
Specified by:
removeApplicationListener in interface ApplicationEventMulticaster
See Also:
ApplicationEventMulticaster.removeApplicationListener(ApplicationListener)

onApplicationEvent

public void onApplicationEvent(ApplicationEvent e)
Description copied from interface: ApplicationListener
Handle an application event
Specified by:
onApplicationEvent in interface ApplicationListener
See Also:
ApplicationListener.onApplicationEvent(ApplicationEvent)

removeAllListeners

public void removeAllListeners()
Description copied from interface: ApplicationEventMulticaster
Remove all listeners registered with this multicaster. It will perform no action on event notification until more listeners are registered.
Specified by:
removeAllListeners in interface ApplicationEventMulticaster
See Also:
ApplicationEventMulticaster.removeAllListeners()


Rod Johnson and Spring contributors 2001-2003.