|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.event.SimpleApplicationEventMulticaster
Simple implementation of the ApplicationEventMulticaster interface. Multicasts all events to all registered listeners.
Doesn't permit multiple instances of the same listener, as it keeps listeners in a HashSet.
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.
Constructor Summary | |
SimpleApplicationEventMulticaster()
|
Method Summary | |
void |
addApplicationListener(ApplicationListener listener)
Add a listener to be notified of all events. |
void |
multicastEvent(ApplicationEvent event)
Multicast the given application event to appropriate listeners. |
void |
removeAllListeners()
Remove all listeners registered with this multicaster. |
void |
removeApplicationListener(ApplicationListener listener)
Remove a listener from the notification list. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SimpleApplicationEventMulticaster()
Method Detail |
public void addApplicationListener(ApplicationListener listener)
ApplicationEventMulticaster
addApplicationListener
in interface ApplicationEventMulticaster
listener
- the listener to addpublic void removeApplicationListener(ApplicationListener listener)
ApplicationEventMulticaster
removeApplicationListener
in interface ApplicationEventMulticaster
listener
- the listener to removepublic void removeAllListeners()
ApplicationEventMulticaster
removeAllListeners
in interface ApplicationEventMulticaster
public void multicastEvent(ApplicationEvent event)
ApplicationEventMulticaster
multicastEvent
in interface ApplicationEventMulticaster
event
- the event to multicast
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |