You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Craig Niles <ni...@gmail.com> on 2015/03/02 02:19:05 UTC

Re: iPOJO Dynamically configured component requirements

Thanks,

It looks like using the factory interface and setting the requires.filters
property through the configuration dictionary does what I want.

On Thu, Feb 26, 2015 at 10:30 AM, clement escoffier <
clement.escoffier@gmail.com> wrote:

> Hi,
>
> You can configure the filters of each service dependency from the instance
> configuration. To achieve this, you need to add the 'requires.filters' key
> inside the configuration. The value is a map dependency id -> filter.
>
> For example, the XML version of this is:
>
> <instance name="FOO2" component="FOO">
>     <property name="requires.filters">
>         <property name="id1" value="(foo.property=BAR)"/>
>     </property></instance>
> <instance name="FOO3" component="FOO">
>     <property name="requires.filters">
>         <property name="id1" value="(foo.property=BAZ)"/>
>     </property></instance>
>
>
> If you want something more dynamic (that you can change at runtime), you
> can either retrieve the `Dependency` object from the instance architecture
> (and from here use the `setFilter` method), or implement an interceptor (
>
> http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/service-binding-interceptors.html
> ).
>
>
> Cheers,
>
> Clement
>
> 2015-02-25 22:20 GMT+01:00 Craig Niles <ni...@gmail.com>:
>
> > Hi,
> >
> > I'm trying to have services created at runtime using the iPOJO Factory
> > API.  The component I want to create an instance of has a requirement on
> > another service, and I use the @Requires annotation.  I know I can
> define a
> > filter for the requirement directly in the @Requires annotation, but how
> > could I achieve the same effect through another API, such as
> @Configuration
> > annotation or Factory API, or even have the requirement use one of the
> > components properties to define which factory it should use?
> >
>