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]

Reply via email to