Based on your response and Clement's I'm going to adopt this methodology. Thanks for the help!
-----Original Message----- From: peter lawrey [mailto:[email protected]] Sent: Monday, June 28, 2010 11:10 AM To: [email protected] Subject: RE: @Requires in iPojo & ServiceListener The problem is that it is assumed that any component can disappear and return at any time, so it's not valid to wait until all components have loaded. The approach I have taken is to use an id @Requires(id="comms") Communications[] comms; @Bind(id="comms") public void onBindCommunications(Communications addedComms) { } @Unbind(id="comms") public void onUnbindCommunications(Communications removedComms) { } Note: I would assume that bind and unbind can be called at any time. -----Original Message----- From: Joel Schuster [mailto:[email protected]] Sent: 28 June 2010 17:28 To: [email protected] Subject: @Requires in iPojo & ServiceListener Having a little issue with @Requires within iPojo. I have an interface (in my case it's called Communications). I also have various implementations of that interface. Within a specific Felix runtime environment there may be multiple instances of a specific implementation (in my case numerous UDPService implementations) and also multiple different implementation instances (both UDPService and SerialService for example) ... all with the same Interface implemented. Using @Requires causes some problems: @Requires Communications[] comms; This ends up giving me all the instances that implement the Communications interface. But only those that have started before the component that has the @Requires. There doesn't seem to be any way to guarantee that all the component instances are started before the array is put together. Even when I use the 'Default-Implementation' attribute this still doesn't give me all of them. I'd like to use a 'Filter' attribute but am having a hard time there too. I've also created a ServiceName interface for all my services to implement that allows me to 'manually' filter through the array based on name. However, if I use something like this: @Requires ServiceName[] allMyServices; I can't cast back to the other interface to do the job that I need. Anyhow. I think there must be a better way that I'm doing it! One thought was to use the ServiceListener interface and wait for everything I'm dependant upon to come up before doing any work. It just seems to be a very non-ipojo way of going about things. Any thoughts would be welcome. - Joel --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

