On 28.03.2017 11:07, erwan wrote:
Hello,
Coming back again to get light!
I have a bundle of questions regarding DS.
How do you use a service without being yourself a service?
You can not use a service without being a service in DS. You can hide your service though. If you set serviceClass to a class in a private package then no other bundle can use this service.
So this works nicely if you have some internal wiring.

I understand that each service is managed by the scr and so need to be
activated at a time. If I have a class that need to do a reference to a
service but that I want to control instantiation, is this possible to
instantiate a service on demand (newInstance?) ?
I think you can create a DS component instance programmatically but I do not remember any more how to do it exactly.

How do you manage to deal with multiple instances of a service?
For example:

class dummy {

@Reference
private Service service1

@Reference
private Service service2

}

For this case you typically use a filter and set a service property on each of the implementing classes.

Btw you can even set a service property for a DS service that you have not written. See http://liquid-reality.de/display/liquid/2016/09/27/Some+hints+to+boost+your+productivity+with+declarative+services
Paragraph "Override service properties using config "

Christian


--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply via email to