Hi Heiko,

Heiko Seeberger schrieb:
> Hi,
> 
> I have got a question that I could not solve looking at the
> specification: Is the activation and deactivation of DS components
> synchronized? I.e. can I be sure, that while I am in the activate method
> SCR will not call the deactivate method or unbind any target services?
> Or do I have to take care about that myself?
> 
> The use case looks like this: A component references some services. As
> this reference uses a static policy, the component will be deactivated
> and re-activated each time a matching service shows up. In my system
> there are several bundles providing such a service, hence at startup
> there happens "a lot of deactivation and activation" which of course has
> to be properly synchronized.

I agree with Simon Archer, that this is not very clearly written down in
the spec. Though, I come to the same conclusions. What I have done in
The Apache Felix implementation, is the following:

* If the service reference is static, the component is deactivated
before changing the binding (as required by the spec). But if the
component is currently being activated, deactivation is scheduled to run
after the activation has completed. Thus it is ensured, that the
component completes activation before being deactivated.
* If the service reference is dynamic, the call to the bind or unbind
method is done immediately. In this case you activate method must be
prepared that a service may be bound or undbound while it is running.

Regards
Felix

> 
> Regards,
> Heiko
> 
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
> 
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to