Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listener/Events

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a name for this java idiom:
Class Listener{
foo( FooEvent f ) { ... } //1
bar( BarEvent b ) { ... } //2
}
I've also seen //1 and //2 collapsed into one method
and FooEvent & BarEvent moved into an inheritance hierachy.
Does this have any relation to "JavaBean event delegation", something I've heard thrown around in discussions ?
Also is this any similar to the Observer design pattern?
Pho

 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pho -
First let's call one out formally, so we can keep out terms clear:

where SomeEvent might then be defined:

These are examples of a listener and event object in an event-delegation model, and their intent is functionally similar to Observer/Observable, so you're right on both counts.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic