org.springframework.richclient.application.support
Class ApplicationEventRedispatcher

java.lang.Object
  extended by org.springframework.richclient.application.support.ApplicationEventRedispatcher
All Implemented Interfaces:
EventListener, ApplicationListener

public class ApplicationEventRedispatcher
extends Object
implements ApplicationListener

This class is responsible for re-dispatching application events to a collection of additional registered listeners. This is needed due to the way that the application context handles the ApplicationListener tag interface. For any beans that are prototypes, one instance will be registered as an ApplicationListener and all the others will not. Further, there is no mechanism to get a reference to the context's event dispatcher to add listeners at runtime.

By defining a bean with this type in the context, it will be added as a typical event listener. Then, this dispatcher can be set on any other bean (including prototypes) that need to be added to the event mechanism. In order to wire it all together, any object that wants to register for events simply defines a property of type ApplicationEventDispatcher and in the property setter method, call the addListener(ApplicationListener) method on itself (or a delegate handler). Like this:

 public void setApplicationEventRedispatcher( ApplicationEventRedispatcher dispatcher ) {
     dispatcher.addListener(this);
 }
 

Author:
Larry Streepy

Constructor Summary
ApplicationEventRedispatcher()
           
 
Method Summary
 void addListener(ApplicationListener l)
          Add a listener to our set.
 void onApplicationEvent(ApplicationEvent event)
          Handle an application event, dispatch it to all our delegates.
 void removeListener(ApplicationListener l)
          Remove a listener from our set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationEventRedispatcher

public ApplicationEventRedispatcher()
Method Detail

onApplicationEvent

public void onApplicationEvent(ApplicationEvent event)
Handle an application event, dispatch it to all our delegates.

Specified by:
onApplicationEvent in interface ApplicationListener
Parameters:
event - to dispatch

addListener

public void addListener(ApplicationListener l)
Add a listener to our set.

Parameters:
l - Listener to add

removeListener

public void removeListener(ApplicationListener l)
Remove a listener from our set.

Parameters:
l - Listener to remove


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.