Can someone point me to a sample involving non-component based event handling? All the samples that i find are event handlers being tied to AWT components? I just wish to write a simple server which calls back on registered listeners(clients),by programmatically raising an event from one of the clients. Any help will be appreciated.
I'm not a fan of Observer and Observable in the library. Before I even found them I made my own pub-sub with an intermediary. The flow is described HERE. I make an interface with methods for the events, implement it once in the intermediary and again in each subscriber. Here's an example with two events:
The abstract Publisher has (dead simple) methods to subscribe and unsubscribe. Some may be offended that I have to copy-paste that little loop for every event. But the flexibility I have here is pretty cool. I can pass parameters and get return types. I could let all the listeners vote on what to do next or let one of them signal that it has consumed the event and stop looping. I can have multiple publishers for the same event. Publishers can come and go while the subscription persists. Good fun.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi