Results 1 to 2 of 2

Thread: How to use addListener method?

  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Default How to use addListener method?

    I have to use a class that uses an addListener() method instead of setListeners()

    How to inject the listener?

  2. #2
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    Some possible choices:

    1) Create a setListener method which just calls addListener (this is a quick but dirty fix);

    2) Dependency inject through constructor arg;

    3) Change your addListener to setListener and refactor;

    4) Use @Autowired directly on the private "listener" attribute (this supposes you have one and only one class of the listener type registered as a Spring bean in the context, either by xml definition or component scanning).

Posting Permissions

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