Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Removing self as a listener

 
Kenneth Winn
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best way for an object to remove itself as a
listener of another object. It was added as a listener in
its ctor.
1) in the finalize method of the object?
2) create a new release() method that can be called by a third
object that 'has a' instance of the listening object?
3) other?
Thanks, Ken
 
Christope Roudet
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use WeakReferences in your listener container.
see Tip 79 in on JavaWorld www.javaworld.com/javaworld/javatips/jw-javatip70_p.html
Christophe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic