Results 1 to 1 of 1

Thread: Event handling targeting prototype beans

  1. #1
    Join Date
    Jul 2007
    Posts
    6

    Question Event handling targeting prototype beans

    Hi all,

    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()?

    Regards,

    Stefan Koulouris


    // 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •