Hi everyone,
I want to know if there is a "clean" way to do this thing.
I've got a class with the following form:
@Component
@Provides
class A {
@Requires
private B[] b;
}
This component is then created by the iPojo API via its factory.
What I would like to do: give a ldap filter on the creation of the instance
in order to have the array that matches the filter.
It is possible to do that offline by giving a filter in the annotation, but
it is impossible to have a dynamic one.
As an example, I use felix/ipojo to manipulate UPnPDevice. I have a generic
component that operate on all the devices that matches the ID given by the
property. Here is how I could do it.
class A {
@Requires
private UPnPDevice[] devices;
@Property
private String udn;
public void foo() {
for all devices that matches the udn {
bar();
}
}
}
But this is a bit silly as I subscribe for all kinds of devices and then I
do manually the filter while it is possible to subscribe to the context that
I want only that filter. The second way, of course, is to ignore iPojo and
subscribe on my own with a custom filter and also manage the list.
It's not the first time I encounter this problem and iPojo has all the tools
to do such thing. Do you know a "clean" way to do it ?
LP