Hi,

Yes, it's exactly what I meant by filter. It's what we are using in
Karaf Decanter.

Cool it fits your need ;)

Regards
JB

On 15/05/2019 16:05, Matthias Leinweber wrote:
> Thank you Tim, 
> 
> 
> Ok thats really amazing! That was exactly what i was looking for. 
> 
> I can change the name target name with @Referance(name="foo") so a bit
> more transparency.
> 
> 
> Each day I am discovering something like this i like OSGI and Karaf a
> bit more. 
> 
> 
> br,
> 
> Matthias
> 
> ------------------------------------------------------------------------
> *Von:* Tim Ward <[email protected]>
> *Gesendet:* Mittwoch, 15. Mai 2019 15:45:20
> *An:* [email protected]
> *Betreff:* Re: Service Sisibility
>  
> Declarative Services is amazing, so this is trivially easy to do. In
> this case you should add the configuration property
> 
>     *service.target*
> 
> 
> to your configuration dictionary with the value being an LDAP filter
> selecting the service you want to inject. 
> 
> Note that “service” is the name of your reference (it defaults to the
> field name) and that if your reference has a different name (e.g. if you
> change the name of the field) then the name of the property will change too.
> 
> For example:
> 
>     service.target=(foo=bar)
> 
> 
> Inject me with a MyInterfaceB which has the service property foo equal
> to bar.
> 
> All the best,
> 
> Tim
> 
>> On 15 May 2019, at 14:35, Matthias Leinweber
>> <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Hello Karaf Experts,
>>
>> i am trying to isolate services from each other. 
>>
>> For Example you have a component:
>>
>> @Component(
>>     configurationPid = "MyInterfacA.factory",
>>     configurationPolicy = ConfigurationPolicy.REQUIRE,
>> public Class MyInterfaceAImpl implements MyInterfacA{
>>
>> @Reference
>> MyInterfaceB service;
>>
>>  ...}
>>
>> During runtime I create multiple services from type MyInterfaceB and
>> multiple componentes of MyInterfaceAImpl with configadmin.
>> Depending on the configuration of MyInterfaceAImpl I want to filter
>> which MyInterfaceB implementation is injected.
>>
>> I thought about FindHook but there I dont see a way how to get the
>> information which service from the bundle is requesting the reference.
>>
>>
>> Is there any chance to do this, or do I have to go for an alternative
>> design. Or a better way to isolate services from another?
>>
>>
>> Best regards,
>> Matthias
> 

-- 
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to