Hi Marco,

this depends on how many services are in your system that can be bound to your reference.

Given the following setup:

@Component
public class AImpl1 {
    @Reference
    private B b;
}

@Component
public class BImpl1 implements B {}

then A gets activated after B has been activated and injected to A. As soon as B is deactivated also A will be deactivated as the reference is per default mandatory and your service A cannot exist without a service B. In this ONE case it does not matter what you defined for policy and policyOption.

This behavior changes as soon as you define your reference to be optional via @Reference(cardinality=ReferenceCardinality.OPTIONAL). Now A can start without B and if the reference is defined to be dynamic activated B services will be injected at runtime as you expect.

For the different combinations of policy and policyOption and their behaviors you should have a look at the Compendium specification at page 303:
https://osgi.org/download/r6/osgi.cmpn-6.0.0.pdf

Kind regards,
Thomas


------ Originalnachricht ------
Von: "MarcoF90" <marco.fierimo...@gmail.com>
An: users@felix.apache.org
Gesendet: 17.11.2017 09:35:07
Betreff: Re: Declarative Services problems in Apache Karaf

Hi Thomas,

thanks for reply. So for mandatory references there is no difference between STATIC, DYNAMIC or GREEDY and RELUCTANT properties? Each time the component
is deactivated?

Kind regards,
Marco



--
Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org

Reply via email to