5 Aug 2010 Kay   » (Journeyer)

Events in Java (Second try)

Well, I'm not that satisfied with the Signal/Slot system I described in a previous article. The reflection part of it makes me itch. So I gave it a second try...

First of all lets summarize the problems with the listener pattern:

  • Two classes (The data container for the event and the listener interface) must be created for each event.
  • At least three methods must be created for each event (Register, Unregister and Fire) in each class which is going to fire the event

So it's simply too much boiler-plate code and the goal is to put as much as possible of it into some library classes without losing any type-safety and without using reflection. I'm going to describe my solution in this article and again I will use the nonsense example of a citizen which drinks some beverage and a Big Brother which monitors it.


Continue reading "Events in Java (Second try)"

Syndicated 2009-06-02 22:14:00 (Updated 2009-06-02 22:30:31) from K's cluttered loft

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!