felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bengt Rodehav <be...@rodehav.com>
Subject iPOJO and dynamic requires
Date Wed, 02 Oct 2013 12:42:52 GMT
I'm creating a dynamic processing component using iPOJO and Camel. The idea
is to dynamically specify (via config admin) a number of processor id's. In
runtime I want to find the matching processors (the processors are Camel
processors published as OSGi services) with the correct id.

E g if I specify a list of services to {A,B} (FileInstall recognizes this
as a list). I want to require those services in order for my iPojo instance
to become valid. It was much harder than I thought.

I've tried something like:

  @Property(name = "processors", mandatory = false, value = "")
  public void setProcessors(String[] theProcessorIds) {
    mProcessorIds = theProcessorIds;
    updateProcessorFilter();
  }

  @Requires
  private Processor[] mProcessors;

The idea is that whenever the configuration property "processors" is
updated, I dynamically update the ldap filter on the dependency
mProcessors. I've used this approach before and it has worked when using a
single dependency (not an array).

The problem is that I want to specifically require each specified
processor. In the example above, I require one processor with id=A AND one
processor with id=B. It's not enough with anyone of them since I want to
invoke them one after another.

Can I use a filter for this? I've been thinking of something like this:

(|(processorId=A)(processorId=B))

This would match both my processors but if one of them were missing my
instance would still become valid which I don't want.

/Bengt

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message