|
From: Mason, R. <ros...@vi...> - 2004-07-13 05:04:58
|
>-----Original Message----- >From: spr...@li... >[mailto:spr...@li...]On Behalf >Of Keith Donald >Sent: Tuesday, 13 July 2004 1:56 PM >To: spring-dev >Subject: [Springframework-developer] application event multicaster > > >I have a need to inject a handle to an application context's=20 >application event multicaster for the purpose of wiring up=20 >application listeners that are instantiated post-startup --=20 >programatically -- within my application. I need this to=20 >happen automagically, e.g where the user doesn't have to=20 >remember to do this. What's the best way to achieve this? =20 >The best I can come up with is to require manual=20 >instantation of an ApplicationEventMulticaster bean in the=20 >context, and inject it automatically using a=20 >BeanPostProcessor (e.g ApplicationEventMulticasterAware). =20 >Is there anyway to get a handle to the default multicaster=20 >associated with an ApplicationContext after the application=20 >has started? You can get the multicaster from the context by calling - applicationContext.getBean(AbstractApplicationContext.APPLICATION_EVENT_M= ULTICASTER_BEAN_NAME); As for setting listeners on the multicaster, Spring already adds any = listeners in the context to the multicaster automatically on startup and = refresh. If you want to programmatically you will need to do it via the = multicaster. Cheers, Ross >=20 >I've considered just having the container instantiate the=20 >ApplicationListener objects in question, but I really want=20 >control over the instantation process--I have to make sure=20 >these objects are prototypes, and I'm slightly concerned=20 >about users forgetting to mark them 'singleton=3Dfalse' within=20 >the context.. this option is not out, but I am preferring=20 >using another object as the "container / factory" for the=20 >prototypes it produces to simplify what the user has to=20 >configure... (it's the view descriptor / view case I emailed=20 >on earlier --> view descriptors produce view instances,=20 >views are prototypes and typically are application event=20 >listeners...) >=20 >Thanks, >Keith >=20 > > >------------------------------------------------------- >This SF.Net email sponsored by Black Hat Briefings & Training. >Attend Black Hat Briefings & Training, Las Vegas July 24-29 -=20 >digital self defense, top technical experts, no vendor pitches,=20 >unmatched networking opportunities. Visit www.blackhat.com >_______________________________________________ >Springframework-developer mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-developer > |