On Monday 19 January 2004 11:01, Stephen McConnell wrote: > Olaf Bergner wrote: > > Are there any best practices for doing what I am trying to achieve? > > Currently, I am thinking about writing a lifecycle extension to that end. > > Is this a feasible solution? Or even better, does anybody have a working > > solution? > > Take a look in merlin cvs.
1. Does it matter if the Service exposes add/remove listener methods? 2. Does the Listener explicitly know about the service producing the events? 3. If so (no on 1, and yes on 2), I think the JavaBeans approach is more than adequate. If one want to a weaker coupling, i.e. the listener doesn't know what sources exists and the producer doesn't manage its listeners, similar to what exists in OSGi. Basically, for a given EventType one can register itself with the container as either a Consumer or Producer. Each doesn't need to know of each other, and when an event is fired, the Producer sends it to the container and the container will distribute it to the Consumers. I think this is a great pattern!!! Can this be implemented without support of the Container?? YES. You need to create a Service that is an EventRouter, where you register the EventType you want to listen to, and where event producers fire its events to. At the moment, Merlin doesn't support "lookup all components that implement a particular interface" but if it did, the EventRouter would just register itself to all known <EventType>Producers. So, either the producer components needs to know explicitly about this pattern, or the EventRouter needs to be partly implemented as a LifeCycle Extension. Ideally, we bring this up on the dev@ list and discusses the introduction into Merlin on a more permanent basis. Niclas --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]