Thanks a lot, will try this approach. /Bengt
2012/11/28 Clement Escoffier <[email protected]> > Hi, > > The DependencyModel is the parent class of all the iPOJO's service > dependencies. So, the easiest way is to access to your service dependency: > > InstanceManager im = (InstanceManager) componentInstance; > DependencyHandler handler = > im.getHandler("org.apache.felix.ipojo:requires"); > Dependencies[] deps = handler.getDependencies(); > // Lookup your dependency from deps (by id, by specification…) > dep.setFilter(filter); > > Regards, > > Clement > > > > > On 28 nov. 2012, at 13:09, Bengt Rodehav <[email protected]> wrote: > > > Thanks for you reply Clement, > > > > So, the following should work (in principal)? > > > > * @Property(name = "myProperty" mandatory = true)* > > * public void setMyPropertey(String theProperty) {* > > * // Calculate new filter based on myProperty* > > * String filter = ....* > > * > > * > > * // How do I get an instance of "DependencyModel"?* > > * DependencyModel.setFilter(filter);* > > * }* > > > > I've never used the DependencyModel class before. How do I gain access to > > the correct instance? What maven artifact do I need for this? > > > > /Bengt > > > > > > 2012/11/28 Clement Escoffier <[email protected]> > > > >> Hi, > >> > >> Using the iPOJO API you can use 'setFilter' to update the LDAP filter > of a > >> dependency (DependencyModel.setFilter). When changed the set of bound > >> services is recomputed. Be aware that it may lead to an invalidation of > the > >> instance if no providers match the new filter. > >> > >> What we did in the past is to develop a handler receiving the new > >> properties, computing the new filter and applying it to the targeted > >> dependency. > >> > >> Regards, > >> > >> Clement > >> > >> On 27 nov. 2012, at 11:41, Bengt Rodehav <[email protected]> wrote: > >> > >>> I'm using the latest iPOJO version. I'm trying to use configuration > >>> properties (via config admin) to make my service wiring dynamic. > >>> > >>> I have handler services that expose service properties (that tells the > >>> world what they can handle). The consumer of these services uses > @Require > >>> with an LDAP filter to specify what needs to be handled and thus limit > >> what > >>> handlers can be used. > >>> > >>> But, I want the LDAP filter to be dynamic so that I can wire up service > >>> providers with service consumers by configuration properties on the > >>> consumers and providers. > >>> > >>> I've tried to buld the LDAP filter dynamically (using a configurable > >>> property) but I get the compilation error: > >>> > >>> * The value for annotation attribute Requires.filter must be a > constant > >>> expression* > >>> > >>> I was hoping that if I changed a configuration property, iPOJO would > >>> refresh its list of provider services to match the changed LDAP filter. > >>> > >>> How can I accomplish what I want? Is there a best practice? > >>> > >>> /Bengt > >> > >> > >> --------------------------------------------------------------------- > >> 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] > >

