Jul 26th, 2007, 05:07 AM
Event handling targeting prototype beans
Does anyone happen to know what the expected behavior is for the standard configuration of event handling, when the class that is targeted is a bean with prototype scope.
From what I see not all instances of this prototype receive applicationEvents.
At a given point registerListeners is executed for the applicationContext, which first looks for statically specified listeners and secondly ads all values the following method returns getBeansOfType(ApplicationListener.class, true, false).values();
This implies that a new instance is created of the prototype and registered as listener.
Newly created instances are not registered and thus receive no application events.
Could this be solved by creating a custom ApplicationEventMulticaster that somehow manages to load instances of a given prototype bean as listeners when executing multicastEvent()?
// Nevermind, solved the problem by setting the applicationEventMulticaster on the class that generates the instances. This way new listeners can be registered.
Last edited by StefanosK; Jul 26th, 2007 at 05:59 AM.